Skip to content

Commit b0db66f

Browse files
refactor: sourceMap option tests (#808)
1 parent dc8464b commit b0db66f

9 files changed

+549
-338
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,21 +217,21 @@ Array [
217217
exports[`import option true: module 1`] = `
218218
"exports = module.exports = require(\\"../../../lib/runtime/api.js\\")(false);
219219
// imports
220-
exports.i(require(\\"-!../../../index.js??ref--4!./test.css\\"), \\"\\");
221-
exports.i(require(\\"-!../../../index.js??ref--4!./test.css\\"), \\"screen and print\\");
222-
exports.i(require(\\"-!../../../index.js??ref--4!./test.css\\"), \\"SCREEN AND PRINT\\");
223-
exports.i(require(\\"-!../../../index.js??ref--4!./test.css\\"), \\"screen and print\\");
224-
exports.i(require(\\"-!../../../index.js??ref--4!./test-media.css\\"), \\"screen and print\\");
225-
exports.i(require(\\"-!../../../index.js??ref--4!./test-other.css\\"), \\"(min-width: 100px)\\");
220+
exports.i(require(\\"-!../../../index.js??ref--4-0!./test.css\\"), \\"\\");
221+
exports.i(require(\\"-!../../../index.js??ref--4-0!./test.css\\"), \\"screen and print\\");
222+
exports.i(require(\\"-!../../../index.js??ref--4-0!./test.css\\"), \\"SCREEN AND PRINT\\");
223+
exports.i(require(\\"-!../../../index.js??ref--4-0!./test.css\\"), \\"screen and print\\");
224+
exports.i(require(\\"-!../../../index.js??ref--4-0!./test-media.css\\"), \\"screen and print\\");
225+
exports.i(require(\\"-!../../../index.js??ref--4-0!./test-other.css\\"), \\"(min-width: 100px)\\");
226226
exports.push([module.id, \\"@import url(http://example.com/style.css);\\", \\"\\"]);
227227
exports.push([module.id, \\"@import url(http://example.com/style.css#hash);\\", \\"\\"]);
228228
exports.push([module.id, \\"@import url(http://example.com/style.css?#hash);\\", \\"\\"]);
229229
exports.push([module.id, \\"@import url(http://example.com/style.css?foo=bar#hash);\\", \\"\\"]);
230230
exports.push([module.id, \\"@import url(http://example.com/other-style.css);\\", \\"screen and print\\"]);
231231
exports.push([module.id, \\"@import url(//example.com/style.css);\\", \\"\\"]);
232-
exports.i(require(\\"-!../../../index.js??ref--4!package/test.css\\"), \\"\\");
233-
exports.i(require(\\"-!../../../index.js??ref--4!./query.css?foo=1&bar=1\\"), \\"\\");
234-
exports.i(require(\\"-!../../../index.js??ref--4!./other-query.css?foo=1&bar=1#hash\\"), \\"\\");
232+
exports.i(require(\\"-!../../../index.js??ref--4-0!package/test.css\\"), \\"\\");
233+
exports.i(require(\\"-!../../../index.js??ref--4-0!./query.css?foo=1&bar=1\\"), \\"\\");
234+
exports.i(require(\\"-!../../../index.js??ref--4-0!./other-query.css?foo=1&bar=1#hash\\"), \\"\\");
235235
236236
// module
237237
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\\", \\"\\"]);

test/__snapshots__/loader.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ exports[`loader should compile with \`css\` entry point: module 1`] = `
171171
"var escape = require(\\"../../lib/runtime/escape.js\\");
172172
exports = module.exports = require(\\"../../lib/runtime/api.js\\")(false);
173173
// imports
174-
exports.i(require(\\"-!../../index.js??ref--4!./imported.css\\"), \\"\\");
174+
exports.i(require(\\"-!../../index.js??ref--4-0!./imported.css\\"), \\"\\");
175175
176176
// module
177177
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\\", \\"\\"]);
@@ -353,7 +353,7 @@ exports[`loader should compile with \`js\` entry point: module 1`] = `
353353
"var escape = require(\\"../../lib/runtime/escape.js\\");
354354
exports = module.exports = require(\\"../../lib/runtime/api.js\\")(false);
355355
// imports
356-
exports.i(require(\\"-!../../index.js??ref--4!./imported.css\\"), \\"\\");
356+
exports.i(require(\\"-!../../index.js??ref--4-0!./imported.css\\"), \\"\\");
357357
358358
// module
359359
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\\", \\"\\"]);
Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`sourceMap option false should not generate source map when source map is \`null\` from other loader: errors 1`] = `Array []`;
4+
5+
exports[`sourceMap option false should not generate source map when source map is \`null\` from other loader: module (evaluated) 1`] = `
6+
Array [
7+
Array [
8+
1,
9+
".class {
10+
color: red;
11+
}
12+
",
13+
"",
14+
],
15+
]
16+
`;
17+
18+
exports[`sourceMap option false should not generate source map when source map is \`null\` from other loader: warnings 1`] = `Array []`;
19+
20+
exports[`sourceMap option false should not generate source map when source map is \`undefined\` from other loader: errors 1`] = `Array []`;
21+
22+
exports[`sourceMap option false should not generate source map when source map is \`undefined\` from other loader: module (evaluated) 1`] = `
23+
Array [
24+
Array [
25+
1,
26+
".class {
27+
color: red;
28+
}
29+
",
30+
"",
31+
],
32+
]
33+
`;
34+
35+
exports[`sourceMap option false should not generate source map when source map is \`undefined\` from other loader: warnings 1`] = `Array []`;
36+
37+
exports[`sourceMap option false should not generate source map when source map is valid and it is string from other loader: errors 1`] = `Array []`;
38+
39+
exports[`sourceMap option false should not generate source map when source map is valid and it is string from other loader: module (evaluated) 1`] = `
40+
Array [
41+
Array [
42+
1,
43+
".class {
44+
color: red;
45+
}
46+
",
47+
"",
48+
],
49+
]
50+
`;
51+
52+
exports[`sourceMap option false should not generate source map when source map is valid and it is string from other loader: warnings 1`] = `Array []`;
53+
54+
exports[`sourceMap option false should not generate source map: errors 1`] = `Array []`;
55+
56+
exports[`sourceMap option false should not generate source map: module (evaluated) 1`] = `
57+
Array [
58+
Array [
59+
1,
60+
".class {
61+
color: red;
62+
}
63+
",
64+
"",
65+
],
66+
]
67+
`;
68+
69+
exports[`sourceMap option false should not generate source map: warnings 1`] = `Array []`;
70+
71+
exports[`sourceMap option false should not generate sourceMap when source map is valid from other loader: errors 1`] = `Array []`;
72+
73+
exports[`sourceMap option false should not generate sourceMap when source map is valid from other loader: module (evaluated) 1`] = `
74+
Array [
75+
Array [
76+
1,
77+
".class {
78+
color: red;
79+
}
80+
",
81+
"",
82+
],
83+
]
84+
`;
85+
86+
exports[`sourceMap option false should not generate sourceMap when source map is valid from other loader: warnings 1`] = `Array []`;
87+
88+
exports[`sourceMap option true should generate source map when source map is \`null\` from other loader: errors 1`] = `Array []`;
89+
90+
exports[`sourceMap option true should generate source map when source map is \`null\` from other loader: module (evaluated) 1`] = `
91+
Array [
92+
Array [
93+
1,
94+
".class {
95+
color: red;
96+
}
97+
",
98+
"",
99+
Object {
100+
"file": "basic.css",
101+
"mappings": "AAAA;EACE,WAAW;CACZ",
102+
"names": Array [],
103+
"sourceRoot": "",
104+
"sources": Array [
105+
"/replaced/original/path/",
106+
],
107+
"sourcesContent": Array [
108+
".class {
109+
color: red;
110+
}
111+
",
112+
],
113+
"version": 3,
114+
},
115+
],
116+
]
117+
`;
118+
119+
exports[`sourceMap option true should generate source map when source map is \`null\` from other loader: warnings 1`] = `Array []`;
120+
121+
exports[`sourceMap option true should generate source map when source map is \`undefined\` from other loader: errors 1`] = `Array []`;
122+
123+
exports[`sourceMap option true should generate source map when source map is \`undefined\` from other loader: module (evaluated) 1`] = `
124+
Array [
125+
Array [
126+
1,
127+
".class {
128+
color: red;
129+
}
130+
",
131+
"",
132+
Object {
133+
"file": "basic.css",
134+
"mappings": "AAAA;EACE,WAAW;CACZ",
135+
"names": Array [],
136+
"sourceRoot": "",
137+
"sources": Array [
138+
"/replaced/original/path/",
139+
],
140+
"sourcesContent": Array [
141+
".class {
142+
color: red;
143+
}
144+
",
145+
],
146+
"version": 3,
147+
},
148+
],
149+
]
150+
`;
151+
152+
exports[`sourceMap option true should generate source map when source map is \`undefined\` from other loader: warnings 1`] = `Array []`;
153+
154+
exports[`sourceMap option true should generate source map when source map is valid and it is string from other loader: errors 1`] = `Array []`;
155+
156+
exports[`sourceMap option true should generate source map when source map is valid and it is string from other loader: module (evaluated) 1`] = `
157+
Array [
158+
Array [
159+
1,
160+
".class {
161+
color: red;
162+
}
163+
",
164+
"",
165+
Object {
166+
"file": "basic.css",
167+
"mappings": "AAAA;ECCE,WAAW;CACZ",
168+
"names": Array [],
169+
"sourceRoot": "",
170+
"sources": Array [
171+
"/replaced/original/path/",
172+
"/replaced/original/path/",
173+
],
174+
"sourcesContent": Array [
175+
".class { a: b c d; }",
176+
".class {
177+
color: red;
178+
}
179+
",
180+
],
181+
"version": 3,
182+
},
183+
],
184+
]
185+
`;
186+
187+
exports[`sourceMap option true should generate source map when source map is valid and it is string from other loader: warnings 1`] = `Array []`;
188+
189+
exports[`sourceMap option true should generate source map when source map is valid from other loader: errors 1`] = `Array []`;
190+
191+
exports[`sourceMap option true should generate source map when source map is valid from other loader: module (evaluated) 1`] = `
192+
Array [
193+
Array [
194+
1,
195+
".class {
196+
color: red;
197+
}
198+
",
199+
"",
200+
Object {
201+
"file": "basic.css",
202+
"mappings": "AAAA;ECCE,WAAW;CACZ",
203+
"names": Array [],
204+
"sourceRoot": "",
205+
"sources": Array [
206+
"/replaced/original/path/",
207+
"/replaced/original/path/",
208+
],
209+
"sourcesContent": Array [
210+
".class { a: b c d; }",
211+
".class {
212+
color: red;
213+
}
214+
",
215+
],
216+
"version": 3,
217+
},
218+
],
219+
]
220+
`;
221+
222+
exports[`sourceMap option true should generate source map when source map is valid from other loader: warnings 1`] = `Array []`;
223+
224+
exports[`sourceMap option true should generate source map: errors 1`] = `Array []`;
225+
226+
exports[`sourceMap option true should generate source map: module (evaluated) 1`] = `
227+
Array [
228+
Array [
229+
1,
230+
".class {
231+
color: red;
232+
}
233+
",
234+
"",
235+
Object {
236+
"file": "basic.css",
237+
"mappings": "AAAA;EACE,WAAW;CACZ",
238+
"names": Array [],
239+
"sourceRoot": "",
240+
"sources": Array [
241+
"/replaced/original/path/",
242+
],
243+
"sourcesContent": Array [
244+
".class {
245+
color: red;
246+
}
247+
",
248+
],
249+
"version": 3,
250+
},
251+
],
252+
]
253+
`;
254+
255+
exports[`sourceMap option true should generate source map: warnings 1`] = `Array []`;

0 commit comments

Comments
 (0)