Skip to content

test: more #1504

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

Merged
merged 1 commit into from
Mar 15, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions test/__snapshots__/import-option.test.js.snap
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a {
color: white;
}
5 changes: 5 additions & 0 deletions test/fixtures/import/list-of-media-queries.css
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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");
});
});