Skip to content

Commit 175729a

Browse files
test: more (#1504)
1 parent badb782 commit 175729a

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed

test/__snapshots__/import-option.test.js.snap

+28
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,34 @@ Error: Can't resolve 'unresolved-file.css' in '/test/fixtures/import'",
354354

355355
exports[`"import" option should throw an error on unresolved import: warnings 1`] = `Array []`;
356356

357+
exports[`"import" option should work and output media: errors 1`] = `Array []`;
358+
359+
exports[`"import" option should work and output media: module 1`] = `
360+
"// Imports
361+
import ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ from \\"../../../src/runtime/noSourceMaps.js\\";
362+
import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\";
363+
import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../src/index.js??ruleSet[1].rules[0].use[0]!./dark.css\\";
364+
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);
365+
___CSS_LOADER_EXPORT___.i(___CSS_LOADER_AT_RULE_IMPORT_0___, \\"(prefers-color-scheme: dark)\\");
366+
// Module
367+
___CSS_LOADER_EXPORT___.push([module.id, \\"a {\\\\n color: black;\\\\n}\\\\n\\", \\"\\"]);
368+
// Exports
369+
export default ___CSS_LOADER_EXPORT___;
370+
"
371+
`;
372+
373+
exports[`"import" option should work and output media: result 1`] = `
374+
"@media (prefers-color-scheme: dark) {a {
375+
color: white;
376+
}
377+
}a {
378+
color: black;
379+
}
380+
"
381+
`;
382+
383+
exports[`"import" option should work and output media: warnings 1`] = `Array []`;
384+
357385
exports[`"import" option should work resolve order: local -> node_modules -> alias: errors 1`] = `Array []`;
358386

359387
exports[`"import" option should work resolve order: local -> node_modules -> alias: module 1`] = `

test/fixtures/import/dark.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
a {
2+
color: white;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import "./dark.css" (prefers-color-scheme: dark);
2+
3+
a {
4+
color: black;
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import css from './list-of-media-queries.css';
2+
3+
__export__ = css.toString();
4+
5+
export default css;

test/import-option.test.js

+14
Original file line numberDiff line numberDiff line change
@@ -574,4 +574,18 @@ describe('"import" option', () => {
574574
expect(getWarnings(stats)).toMatchSnapshot("warnings");
575575
expect(getErrors(stats)).toMatchSnapshot("errors");
576576
});
577+
578+
it("should work and output media", async () => {
579+
const compiler = getCompiler("./import/list-of-media-queries.js");
580+
const stats = await compile(compiler);
581+
582+
expect(
583+
getModuleSource("./import/list-of-media-queries.css", stats)
584+
).toMatchSnapshot("module");
585+
expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot(
586+
"result"
587+
);
588+
expect(getWarnings(stats)).toMatchSnapshot("warnings");
589+
expect(getErrors(stats)).toMatchSnapshot("errors");
590+
});
577591
});

0 commit comments

Comments
 (0)