From 1afde1dd5f610719450ab454e7893f138fdd3842 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Wed, 17 Jul 2019 23:32:19 +0300 Subject: [PATCH] test: escaped in selectors --- .../__snapshots__/modules-option.test.js.snap | 27 +++++++++++++++++++ test/fixtures/modules/issue-966/button.css | 3 +++ test/fixtures/modules/issue-966/toolbar.css | 5 ++++ test/modules-option.test.js | 24 +++++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 test/fixtures/modules/issue-966/button.css create mode 100644 test/fixtures/modules/issue-966/toolbar.css diff --git a/test/__snapshots__/modules-option.test.js.snap b/test/__snapshots__/modules-option.test.js.snap index bee42f83..6be32a97 100644 --- a/test/__snapshots__/modules-option.test.js.snap +++ b/test/__snapshots__/modules-option.test.js.snap @@ -6355,6 +6355,33 @@ exports.locals = { exports[`modules issue #861: warnings 1`] = `Array []`; +exports[`modules issue #966: errors 1`] = `Array []`; + +exports[`modules issue #966: module (evaluated) 1`] = ` +Array [ + Array [ + 1, + ".button.hey { + color: red; +} +", + "", + ], +] +`; + +exports[`modules issue #966: module 1`] = ` +"exports = module.exports = require(\\"../../../../src/runtime/api.js\\")(false); +// Module +exports.push([module.id, \\".button.hey {\\\\n color: red;\\\\n}\\\\n\\", \\"\\"]); +// Exports +exports.locals = { + \\"button\\": \\"button.hey\\" +};" +`; + +exports[`modules issue #966: warnings 1`] = `Array []`; + exports[`modules issue #967: errors 1`] = `Array []`; exports[`modules issue #967: module (evaluated) 1`] = ` diff --git a/test/fixtures/modules/issue-966/button.css b/test/fixtures/modules/issue-966/button.css new file mode 100644 index 00000000..1dfac231 --- /dev/null +++ b/test/fixtures/modules/issue-966/button.css @@ -0,0 +1,3 @@ +.button { + color: red; +} diff --git a/test/fixtures/modules/issue-966/toolbar.css b/test/fixtures/modules/issue-966/toolbar.css new file mode 100644 index 00000000..ca5da320 --- /dev/null +++ b/test/fixtures/modules/issue-966/toolbar.css @@ -0,0 +1,5 @@ +@value btn from './button.css'; + +.toolbar > btn { + color: red +} diff --git a/test/modules-option.test.js b/test/modules-option.test.js index a11fe3ab..2bbf7837 100644 --- a/test/modules-option.test.js +++ b/test/modules-option.test.js @@ -485,4 +485,28 @@ describe('modules', () => { expect(stats.compilation.warnings).toMatchSnapshot('warnings'); expect(stats.compilation.errors).toMatchSnapshot('errors'); }); + + it('issue #966', async () => { + const config = { + loader: { + options: { + modules: { + getLocalIdent: (ctx, localIdentName, localName) => + `${localName}.hey`, + }, + }, + }, + }; + const testId = './modules/issue-966/button.css'; + const stats = await webpack(testId, config); + const { modules } = stats.toJson(); + const module = modules.find((m) => m.id === testId); + + expect(module.source).toMatchSnapshot('module'); + expect(evaluated(module.source, modules)).toMatchSnapshot( + 'module (evaluated)' + ); + expect(stats.compilation.warnings).toMatchSnapshot('warnings'); + expect(stats.compilation.errors).toMatchSnapshot('errors'); + }); });