Skip to content

Commit

Permalink
test: issue 636 (#853)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Dec 5, 2018
1 parent 08c551c commit 533abbe
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 2 deletions.
36 changes: 36 additions & 0 deletions test/__snapshots__/modules-option.test.js.snap
Expand Up @@ -5342,3 +5342,39 @@ exports.locals = {
`;
exports[`modules issue #286: warnings 1`] = `Array []`;
exports[`modules issue #636: errors 1`] = `Array []`;
exports[`modules issue #636: module (evaluated) 1`] = `
Array [
Array [
2,
".prefix-foo {
color: red;
}",
"",
],
Array [
1,
".prefix-bar {
}",
"",
],
]
`;
exports[`modules issue #636: module 1`] = `
"exports = module.exports = require(\\"../../../../src/runtime/api.js\\")(false);
// imports
exports.i(require(\\"-!../../../../src/index.js??ref--4-0!../../../../node_modules/sass-loader/lib/loader.js??ref--4-1!./foo.scss\\"), \\"\\");
// module
exports.push([module.id, \\".prefix-bar {\\\\n}\\", \\"\\"]);
// exports
exports.locals = {
\\"bar\\": \\"prefix-bar \\" + require(\\"-!../../../../src/index.js??ref--4-0!../../../../node_modules/sass-loader/lib/loader.js??ref--4-1!./foo.scss\\").locals[\\"foo\\"] + \\"\\"
};"
`;
exports[`modules issue #636: warnings 1`] = `Array []`;
3 changes: 3 additions & 0 deletions test/fixtures/modules/issue-636/foo.scss
@@ -0,0 +1,3 @@
.foo {
color: red;
}
3 changes: 3 additions & 0 deletions test/fixtures/modules/issue-636/source.scss
@@ -0,0 +1,3 @@
.bar {
composes: foo from "./foo.scss";
}
1 change: 1 addition & 0 deletions test/helpers.js
Expand Up @@ -42,6 +42,7 @@ function evaluated(output, modules, moduleId = 1) {
'url/node_modules',
'modules/',
'modules/issue-286',
'modules/issue-636',
'modules/node_modules',
'modules/tests-cases/urls',
'modules/tests-cases/issue-589',
Expand Down
35 changes: 33 additions & 2 deletions test/modules-option.test.js
Expand Up @@ -37,7 +37,7 @@ describe('modules', () => {
});
});

it(`composes should supports resolving`, async () => {
it('composes should supports resolving', async () => {
const config = {
loader: { options: { import: true, modules: true } },
};
Expand All @@ -54,7 +54,7 @@ describe('modules', () => {
expect(stats.compilation.errors).toMatchSnapshot('errors');
});

it(`issue #286`, async () => {
it('issue #286', async () => {
const config = {
loader: {
test: /source\.css$/,
Expand Down Expand Up @@ -86,4 +86,35 @@ describe('modules', () => {
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
expect(stats.compilation.errors).toMatchSnapshot('errors');
});

it('issue #636', async () => {
const config = {
loader: {
test: /\.s[ca]ss$/i,
options: {
modules: true,
importLoaders: 1,
localIdentName: '[local]',
getLocalIdent: (context, localIdentName, localName) =>
`prefix-${localName}`,
},
},
sassLoader: true,
sassLoaderOptions: {
// eslint-disable-next-line global-require
implementation: require('sass'),
},
};
const testId = './modules/issue-636/source.scss';
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');
});
});

0 comments on commit 533abbe

Please sign in to comment.