Skip to content

Commit

Permalink
test: more (#1504)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Mar 15, 2023
1 parent badb782 commit 175729a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/__snapshots__/import-option.test.js.snap
Expand Up @@ -354,6 +354,34 @@ Error: Can't resolve 'unresolved-file.css' in '/test/fixtures/import'",

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

exports[`"import" option should work and output media: errors 1`] = `Array []`;

exports[`"import" option should work and output media: module 1`] = `
"// Imports
import ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ from \\"../../../src/runtime/noSourceMaps.js\\";
import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\";
import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../src/index.js??ruleSet[1].rules[0].use[0]!./dark.css\\";
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);
___CSS_LOADER_EXPORT___.i(___CSS_LOADER_AT_RULE_IMPORT_0___, \\"(prefers-color-scheme: dark)\\");
// Module
___CSS_LOADER_EXPORT___.push([module.id, \\"a {\\\\n color: black;\\\\n}\\\\n\\", \\"\\"]);
// Exports
export default ___CSS_LOADER_EXPORT___;
"
`;

exports[`"import" option should work and output media: result 1`] = `
"@media (prefers-color-scheme: dark) {a {
color: white;
}
}a {
color: black;
}
"
`;

exports[`"import" option should work and output media: warnings 1`] = `Array []`;

exports[`"import" option should work resolve order: local -> node_modules -> alias: errors 1`] = `Array []`;

exports[`"import" option should work resolve order: local -> node_modules -> alias: module 1`] = `
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/import/dark.css
@@ -0,0 +1,3 @@
a {
color: white;
}
5 changes: 5 additions & 0 deletions test/fixtures/import/list-of-media-queries.css
@@ -0,0 +1,5 @@
@import "./dark.css" (prefers-color-scheme: dark);

a {
color: black;
}
5 changes: 5 additions & 0 deletions test/fixtures/import/list-of-media-queries.js
@@ -0,0 +1,5 @@
import css from './list-of-media-queries.css';

__export__ = css.toString();

export default css;
14 changes: 14 additions & 0 deletions test/import-option.test.js
Expand Up @@ -574,4 +574,18 @@ describe('"import" option', () => {
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});

it("should work and output media", async () => {
const compiler = getCompiler("./import/list-of-media-queries.js");
const stats = await compile(compiler);

expect(
getModuleSource("./import/list-of-media-queries.css", stats)
).toMatchSnapshot("module");
expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot(
"result"
);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
});

0 comments on commit 175729a

Please sign in to comment.