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

refactor: sourceMap option tests #808

Merged
merged 1 commit into from
Nov 27, 2018
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
18 changes: 9 additions & 9 deletions test/__snapshots__/import-option.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -217,21 +217,21 @@ Array [
exports[`import option true: module 1`] = `
"exports = module.exports = require(\\"../../../lib/runtime/api.js\\")(false);
// imports
exports.i(require(\\"-!../../../index.js??ref--4!./test.css\\"), \\"\\");
exports.i(require(\\"-!../../../index.js??ref--4!./test.css\\"), \\"screen and print\\");
exports.i(require(\\"-!../../../index.js??ref--4!./test.css\\"), \\"SCREEN AND PRINT\\");
exports.i(require(\\"-!../../../index.js??ref--4!./test.css\\"), \\"screen and print\\");
exports.i(require(\\"-!../../../index.js??ref--4!./test-media.css\\"), \\"screen and print\\");
exports.i(require(\\"-!../../../index.js??ref--4!./test-other.css\\"), \\"(min-width: 100px)\\");
exports.i(require(\\"-!../../../index.js??ref--4-0!./test.css\\"), \\"\\");
exports.i(require(\\"-!../../../index.js??ref--4-0!./test.css\\"), \\"screen and print\\");
exports.i(require(\\"-!../../../index.js??ref--4-0!./test.css\\"), \\"SCREEN AND PRINT\\");
exports.i(require(\\"-!../../../index.js??ref--4-0!./test.css\\"), \\"screen and print\\");
exports.i(require(\\"-!../../../index.js??ref--4-0!./test-media.css\\"), \\"screen and print\\");
exports.i(require(\\"-!../../../index.js??ref--4-0!./test-other.css\\"), \\"(min-width: 100px)\\");
exports.push([module.id, \\"@import url(http://example.com/style.css);\\", \\"\\"]);
exports.push([module.id, \\"@import url(http://example.com/style.css#hash);\\", \\"\\"]);
exports.push([module.id, \\"@import url(http://example.com/style.css?#hash);\\", \\"\\"]);
exports.push([module.id, \\"@import url(http://example.com/style.css?foo=bar#hash);\\", \\"\\"]);
exports.push([module.id, \\"@import url(http://example.com/other-style.css);\\", \\"screen and print\\"]);
exports.push([module.id, \\"@import url(//example.com/style.css);\\", \\"\\"]);
exports.i(require(\\"-!../../../index.js??ref--4!package/test.css\\"), \\"\\");
exports.i(require(\\"-!../../../index.js??ref--4!./query.css?foo=1&bar=1\\"), \\"\\");
exports.i(require(\\"-!../../../index.js??ref--4!./other-query.css?foo=1&bar=1#hash\\"), \\"\\");
exports.i(require(\\"-!../../../index.js??ref--4-0!package/test.css\\"), \\"\\");
exports.i(require(\\"-!../../../index.js??ref--4-0!./query.css?foo=1&bar=1\\"), \\"\\");
exports.i(require(\\"-!../../../index.js??ref--4-0!./other-query.css?foo=1&bar=1#hash\\"), \\"\\");

// module
exports.push([module.id, \\"@import URL(test.css);\\\\n@import url();\\\\n@import url('');\\\\n@import url(\\\\\\"\\\\\\");\\\\n@import '';\\\\n@import \\\\\\"\\\\\\";\\\\n@import \\\\\\" \\\\\\";\\\\n@import \\\\\\"\\\\n\\\\\\";\\\\n@import url();\\\\n@import url('');\\\\n@import url(\\\\\\"\\\\\\");\\\\n@import ;\\\\n@import foo-bar;\\\\n@import-normalize;\\\\n@import url('http://') :root {}\\\\n\\\\n.class {\\\\n a: b c d;\\\\n}\\\\n\\\\n.foo {\\\\n @import 'path.css';\\\\n}\\\\n\\", \\"\\"]);
Expand Down
4 changes: 2 additions & 2 deletions test/__snapshots__/loader.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ exports[`loader should compile with \`css\` entry point: module 1`] = `
"var escape = require(\\"../../lib/runtime/escape.js\\");
exports = module.exports = require(\\"../../lib/runtime/api.js\\")(false);
// imports
exports.i(require(\\"-!../../index.js??ref--4!./imported.css\\"), \\"\\");
exports.i(require(\\"-!../../index.js??ref--4-0!./imported.css\\"), \\"\\");

// module
exports.push([module.id, \\"@charset \\\\\\"UTF-8\\\\\\";\\\\n\\\\n/* Comment */\\\\n\\\\n.class {\\\\n color: red;\\\\n background: url(\\" + escape(require(\\"./url/img.png\\")) + \\");\\\\n}\\\\n\\\\n.class-duplicate-url {\\\\n background: url(\\" + escape(require(\\"./url/img.png\\")) + \\");\\\\n}\\\\n\\\\n:root {\\\\n --foo: 1px;\\\\n --bar: 2px;\\\\n}\\\\n\\\\n.class { a: b c d; }\\\\n\\\\n.two {}\\\\n\\\\n.u-m\\\\\\\\+ { a: b c d; }\\\\n\\\\n.class { content: \\\\\\"\\\\\\\\F10C\\\\\\" }\\\\n\\\\n@media only screen and (max-width: 600px) {\\\\n body {\\\\n background-color: lightblue;\\\\n }\\\\n}\\\\n\\\\n/*\\\\nNeed uncomment after resolve https://github.com/css-modules/postcss-modules-local-by-default/issues/108\\\\n\\\\n.class {\\\\n content: \\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\f10C\\\\\\\\\\\\\\"\\\\n}\\\\n\\\\n.class {\\\\n content: \\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\F10C \\\\\\\\\\\\\\\\F10D\\\\\\\\\\\\\\"\\\\n}\\\\n*/\\\\n\\", \\"\\"]);
Expand Down Expand Up @@ -353,7 +353,7 @@ exports[`loader should compile with \`js\` entry point: module 1`] = `
"var escape = require(\\"../../lib/runtime/escape.js\\");
exports = module.exports = require(\\"../../lib/runtime/api.js\\")(false);
// imports
exports.i(require(\\"-!../../index.js??ref--4!./imported.css\\"), \\"\\");
exports.i(require(\\"-!../../index.js??ref--4-0!./imported.css\\"), \\"\\");

// module
exports.push([module.id, \\"@charset \\\\\\"UTF-8\\\\\\";\\\\n\\\\n/* Comment */\\\\n\\\\n.class {\\\\n color: red;\\\\n background: url(\\" + escape(require(\\"./url/img.png\\")) + \\");\\\\n}\\\\n\\\\n.class-duplicate-url {\\\\n background: url(\\" + escape(require(\\"./url/img.png\\")) + \\");\\\\n}\\\\n\\\\n:root {\\\\n --foo: 1px;\\\\n --bar: 2px;\\\\n}\\\\n\\\\n.class { a: b c d; }\\\\n\\\\n.two {}\\\\n\\\\n.u-m\\\\\\\\+ { a: b c d; }\\\\n\\\\n.class { content: \\\\\\"\\\\\\\\F10C\\\\\\" }\\\\n\\\\n@media only screen and (max-width: 600px) {\\\\n body {\\\\n background-color: lightblue;\\\\n }\\\\n}\\\\n\\\\n/*\\\\nNeed uncomment after resolve https://github.com/css-modules/postcss-modules-local-by-default/issues/108\\\\n\\\\n.class {\\\\n content: \\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\f10C\\\\\\\\\\\\\\"\\\\n}\\\\n\\\\n.class {\\\\n content: \\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\F10C \\\\\\\\\\\\\\\\F10D\\\\\\\\\\\\\\"\\\\n}\\\\n*/\\\\n\\", \\"\\"]);
Expand Down
255 changes: 255 additions & 0 deletions test/__snapshots__/sourceMap-option.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`sourceMap option false should not generate source map when source map is \`null\` from other loader: errors 1`] = `Array []`;

exports[`sourceMap option false should not generate source map when source map is \`null\` from other loader: module (evaluated) 1`] = `
Array [
Array [
1,
".class {
color: red;
}
",
"",
],
]
`;

exports[`sourceMap option false should not generate source map when source map is \`null\` from other loader: warnings 1`] = `Array []`;

exports[`sourceMap option false should not generate source map when source map is \`undefined\` from other loader: errors 1`] = `Array []`;

exports[`sourceMap option false should not generate source map when source map is \`undefined\` from other loader: module (evaluated) 1`] = `
Array [
Array [
1,
".class {
color: red;
}
",
"",
],
]
`;

exports[`sourceMap option false should not generate source map when source map is \`undefined\` from other loader: warnings 1`] = `Array []`;

exports[`sourceMap option false should not generate source map when source map is valid and it is string from other loader: errors 1`] = `Array []`;

exports[`sourceMap option false should not generate source map when source map is valid and it is string from other loader: module (evaluated) 1`] = `
Array [
Array [
1,
".class {
color: red;
}
",
"",
],
]
`;

exports[`sourceMap option false should not generate source map when source map is valid and it is string from other loader: warnings 1`] = `Array []`;

exports[`sourceMap option false should not generate source map: errors 1`] = `Array []`;

exports[`sourceMap option false should not generate source map: module (evaluated) 1`] = `
Array [
Array [
1,
".class {
color: red;
}
",
"",
],
]
`;

exports[`sourceMap option false should not generate source map: warnings 1`] = `Array []`;

exports[`sourceMap option false should not generate sourceMap when source map is valid from other loader: errors 1`] = `Array []`;

exports[`sourceMap option false should not generate sourceMap when source map is valid from other loader: module (evaluated) 1`] = `
Array [
Array [
1,
".class {
color: red;
}
",
"",
],
]
`;

exports[`sourceMap option false should not generate sourceMap when source map is valid from other loader: warnings 1`] = `Array []`;

exports[`sourceMap option true should generate source map when source map is \`null\` from other loader: errors 1`] = `Array []`;

exports[`sourceMap option true should generate source map when source map is \`null\` from other loader: module (evaluated) 1`] = `
Array [
Array [
1,
".class {
color: red;
}
",
"",
Object {
"file": "basic.css",
"mappings": "AAAA;EACE,WAAW;CACZ",
"names": Array [],
"sourceRoot": "",
"sources": Array [
"/replaced/original/path/",
],
"sourcesContent": Array [
".class {
color: red;
}
",
],
"version": 3,
},
],
]
`;

exports[`sourceMap option true should generate source map when source map is \`null\` from other loader: warnings 1`] = `Array []`;

exports[`sourceMap option true should generate source map when source map is \`undefined\` from other loader: errors 1`] = `Array []`;

exports[`sourceMap option true should generate source map when source map is \`undefined\` from other loader: module (evaluated) 1`] = `
Array [
Array [
1,
".class {
color: red;
}
",
"",
Object {
"file": "basic.css",
"mappings": "AAAA;EACE,WAAW;CACZ",
"names": Array [],
"sourceRoot": "",
"sources": Array [
"/replaced/original/path/",
],
"sourcesContent": Array [
".class {
color: red;
}
",
],
"version": 3,
},
],
]
`;

exports[`sourceMap option true should generate source map when source map is \`undefined\` from other loader: warnings 1`] = `Array []`;

exports[`sourceMap option true should generate source map when source map is valid and it is string from other loader: errors 1`] = `Array []`;

exports[`sourceMap option true should generate source map when source map is valid and it is string from other loader: module (evaluated) 1`] = `
Array [
Array [
1,
".class {
color: red;
}
",
"",
Object {
"file": "basic.css",
"mappings": "AAAA;ECCE,WAAW;CACZ",
"names": Array [],
"sourceRoot": "",
"sources": Array [
"/replaced/original/path/",
"/replaced/original/path/",
],
"sourcesContent": Array [
".class { a: b c d; }",
".class {
color: red;
}
",
],
"version": 3,
},
],
]
`;

exports[`sourceMap option true should generate source map when source map is valid and it is string from other loader: warnings 1`] = `Array []`;

exports[`sourceMap option true should generate source map when source map is valid from other loader: errors 1`] = `Array []`;

exports[`sourceMap option true should generate source map when source map is valid from other loader: module (evaluated) 1`] = `
Array [
Array [
1,
".class {
color: red;
}
",
"",
Object {
"file": "basic.css",
"mappings": "AAAA;ECCE,WAAW;CACZ",
"names": Array [],
"sourceRoot": "",
"sources": Array [
"/replaced/original/path/",
"/replaced/original/path/",
],
"sourcesContent": Array [
".class { a: b c d; }",
".class {
color: red;
}
",
],
"version": 3,
},
],
]
`;

exports[`sourceMap option true should generate source map when source map is valid from other loader: warnings 1`] = `Array []`;

exports[`sourceMap option true should generate source map: errors 1`] = `Array []`;

exports[`sourceMap option true should generate source map: module (evaluated) 1`] = `
Array [
Array [
1,
".class {
color: red;
}
",
"",
Object {
"file": "basic.css",
"mappings": "AAAA;EACE,WAAW;CACZ",
"names": Array [],
"sourceRoot": "",
"sources": Array [
"/replaced/original/path/",
],
"sourcesContent": Array [
".class {
color: red;
}
",
],
"version": 3,
},
],
]
`;

exports[`sourceMap option true should generate source map: warnings 1`] = `Array []`;
Loading