From 62e8253c564b8bb75cbe87fa9d912ded682425f1 Mon Sep 17 00:00:00 2001 From: Alexander Akait Date: Fri, 13 Nov 2020 19:47:43 +0300 Subject: [PATCH] test: animation properties (#1229) --- .../__snapshots__/modules-option.test.js.snap | 50 +++++++++++++++++++ test/fixtures/modules/issue-1228/source.css | 20 ++++++++ test/fixtures/modules/issue-1228/source.js | 5 ++ test/modules-option.test.js | 16 ++++++ 4 files changed, 91 insertions(+) create mode 100644 test/fixtures/modules/issue-1228/source.css create mode 100644 test/fixtures/modules/issue-1228/source.js diff --git a/test/__snapshots__/modules-option.test.js.snap b/test/__snapshots__/modules-option.test.js.snap index db80b85c..ce94d1aa 100644 --- a/test/__snapshots__/modules-option.test.js.snap +++ b/test/__snapshots__/modules-option.test.js.snap @@ -12472,6 +12472,56 @@ Array [ exports[`"modules" option should work with the "[local]" placeholder for the "localIdentName" option: warnings 1`] = `Array []`; +exports[`"modules" option should work with the "animation" : errors 1`] = `Array []`; + +exports[`"modules" option should work with the "animation" : module 1`] = ` +"// Imports +import ___CSS_LOADER_API_IMPORT___ from \\"../../../../src/runtime/api.js\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(function(i){return i[1]}); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \\"._2D_a3nRJzeYYTHGyq4Flnv {\\\\n animation: 3s _1mfCY-QJoM3OC5uQJynmBJ;\\\\n}\\\\n\\\\n._2PJ0C1A-J6DQoUOkoQ0iJf {\\\\n animation: _1mfCY-QJoM3OC5uQJynmBJ 3s;\\\\n}\\\\n\\\\n._3YD2YkzQKZPR2NHYPjUkly {\\\\n animation-name: _1mfCY-QJoM3OC5uQJynmBJ;\\\\n}\\\\n\\\\n@keyframes _1mfCY-QJoM3OC5uQJynmBJ {\\\\n 0% {\\\\n background: white;\\\\n }\\\\n 100% {\\\\n background: red;\\\\n }\\\\n}\\", \\"\\"]); +// Exports +___CSS_LOADER_EXPORT___.locals = { + \\"a\\": \\"_2D_a3nRJzeYYTHGyq4Flnv\\", + \\"animationName\\": \\"_1mfCY-QJoM3OC5uQJynmBJ\\", + \\"b\\": \\"_2PJ0C1A-J6DQoUOkoQ0iJf\\", + \\"c\\": \\"_3YD2YkzQKZPR2NHYPjUkly\\" +}; +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"modules" option should work with the "animation" : result 1`] = ` +Array [ + Array [ + "./modules/issue-1228/source.css", + "._2D_a3nRJzeYYTHGyq4Flnv { + animation: 3s _1mfCY-QJoM3OC5uQJynmBJ; +} + +._2PJ0C1A-J6DQoUOkoQ0iJf { + animation: _1mfCY-QJoM3OC5uQJynmBJ 3s; +} + +._3YD2YkzQKZPR2NHYPjUkly { + animation-name: _1mfCY-QJoM3OC5uQJynmBJ; +} + +@keyframes _1mfCY-QJoM3OC5uQJynmBJ { + 0% { + background: white; + } + 100% { + background: red; + } +}", + "", + ], +] +`; + +exports[`"modules" option should work with the "animation" : warnings 1`] = `Array []`; + exports[`"modules" option should work with the "auto" by default for icss: errors 1`] = `Array []`; exports[`"modules" option should work with the "auto" by default for icss: module 1`] = ` diff --git a/test/fixtures/modules/issue-1228/source.css b/test/fixtures/modules/issue-1228/source.css new file mode 100644 index 00000000..7da41d8a --- /dev/null +++ b/test/fixtures/modules/issue-1228/source.css @@ -0,0 +1,20 @@ +.a { + animation: 3s animationName; +} + +.b { + animation: animationName 3s; +} + +.c { + animation-name: animationName; +} + +@keyframes animationName { + 0% { + background: white; + } + 100% { + background: red; + } +} \ No newline at end of file diff --git a/test/fixtures/modules/issue-1228/source.js b/test/fixtures/modules/issue-1228/source.js new file mode 100644 index 00000000..1996779e --- /dev/null +++ b/test/fixtures/modules/issue-1228/source.js @@ -0,0 +1,5 @@ +import css from './source.css'; + +__export__ = css; + +export default css; diff --git a/test/modules-option.test.js b/test/modules-option.test.js index 91c93b1f..6116a689 100644 --- a/test/modules-option.test.js +++ b/test/modules-option.test.js @@ -1473,4 +1473,20 @@ describe('"modules" option', () => { expect(getWarnings(stats)).toMatchSnapshot('warnings'); expect(getErrors(stats)).toMatchSnapshot('errors'); }); + + it('should work with the "animation" ', async () => { + const compiler = getCompiler('./modules/issue-1228/source.js', { + modules: { mode: 'local' }, + }); + const stats = await compile(compiler); + + expect( + getModuleSource('./modules/issue-1228/source.css', stats) + ).toMatchSnapshot('module'); + expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( + 'result' + ); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); + }); });