Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: escaped in selector #973

Merged
merged 1 commit into from Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions test/__snapshots__/modules-option.test.js.snap
Expand Up @@ -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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bug is right here: .button.hey is very different than: .button\.hey. The former is a selector for when both .button and .hey are on an element

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\\"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also wrong, but if you escaped in getLocalIdent it would be fixed

};"
`;

exports[`modules issue #966: warnings 1`] = `Array []`;

exports[`modules issue #967: errors 1`] = `Array []`;

exports[`modules issue #967: module (evaluated) 1`] = `
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/modules/issue-966/button.css
@@ -0,0 +1,3 @@
.button {
color: red;
}
5 changes: 5 additions & 0 deletions test/fixtures/modules/issue-966/toolbar.css
@@ -0,0 +1,5 @@
@value btn from './button.css';

.toolbar > btn {
color: red
}
24 changes: 24 additions & 0 deletions test/modules-option.test.js
Expand Up @@ -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');
});
});