Skip to content

Commit ea26c56

Browse files
test: refactor
* test: refactor * test: refactor url option test * test: refactor onlyLocals option test * test: refactor import option test * test: refactor localsConvention option test * test: refactor * test: refactor icss * test: refactor importLoaders option * test: refactor loader code * test: refactor modules code * test: refactor sourceMap code * test: refactor * test: refactor * test: refactor * test: refactor * test: refactor * test: refactor * test: refactor * test: refactor * test: refactor * test: refactor * test: refactor * test: refactor * test: refactor * test: refactor
1 parent ee40727 commit ea26c56

File tree

128 files changed

+12630
-9915
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+12630
-9915
lines changed

src/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ function normalizeSourceMap(map) {
162162
// Some loader emit source map as string
163163
// Strip any JSON XSSI avoidance prefix from the string (as documented in the source maps specification), and then parse the string as JSON.
164164
if (typeof newMap === 'string') {
165-
newMap = JSON.parse(newMap.replace(/^\)]}'[^\n]*\n/, ''));
165+
newMap = JSON.parse(newMap);
166166
}
167167

168168
// Source maps should use forward slash because it is URLs (https://github.com/mozilla/source-map/issues/91)

test/__snapshots__/icss.test.js.snap

+160-94
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,188 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`ICSS case duplicate-export: errors 1`] = `Array []`;
4-
5-
exports[`ICSS case duplicate-export: locals 1`] = `
6-
Object {
7-
"_test": "_right_value",
8-
}
3+
exports[`ICSS show work with the case "duplicate-export": errors 1`] = `Array []`;
4+
5+
exports[`ICSS show work with the case "duplicate-export": module 1`] = `
6+
"// Imports
7+
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
8+
exports = module.exports = ___CSS_LOADER_API_IMPORT___(false);
9+
// Module
10+
exports.push([module.id, \\"\\\\n\\", \\"\\"]);
11+
// Exports
12+
exports.locals = {
13+
\\"_test\\": \\"_right_value\\"
14+
};"
915
`;
1016

11-
exports[`ICSS case duplicate-export: module (evaluated) 1`] = `
17+
exports[`ICSS show work with the case "duplicate-export": result 1`] = `
1218
Array [
1319
Array [
14-
1,
20+
"./icss/tests-cases/duplicate-export/source.css",
1521
"
1622
",
1723
"",
1824
],
1925
]
2026
`;
2127

22-
exports[`ICSS case duplicate-export: warnings 1`] = `Array []`;
28+
exports[`ICSS show work with the case "duplicate-export": warnings 1`] = `Array []`;
2329

24-
exports[`ICSS case duplicate-export-in-multiple-export: errors 1`] = `Array []`;
30+
exports[`ICSS show work with the case "duplicate-export-in-multiple-export": errors 1`] = `Array []`;
2531

26-
exports[`ICSS case duplicate-export-in-multiple-export: locals 1`] = `
27-
Object {
28-
"_test": "_right_value",
29-
}
32+
exports[`ICSS show work with the case "duplicate-export-in-multiple-export": module 1`] = `
33+
"// Imports
34+
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
35+
exports = module.exports = ___CSS_LOADER_API_IMPORT___(false);
36+
// Module
37+
exports.push([module.id, \\"\\\\n\\", \\"\\"]);
38+
// Exports
39+
exports.locals = {
40+
\\"_test\\": \\"_right_value\\"
41+
};"
3042
`;
3143

32-
exports[`ICSS case duplicate-export-in-multiple-export: module (evaluated) 1`] = `
44+
exports[`ICSS show work with the case "duplicate-export-in-multiple-export": result 1`] = `
3345
Array [
3446
Array [
35-
1,
47+
"./icss/tests-cases/duplicate-export-in-multiple-export/source.css",
3648
"
3749
",
3850
"",
3951
],
4052
]
4153
`;
4254

43-
exports[`ICSS case duplicate-export-in-multiple-export: warnings 1`] = `Array []`;
55+
exports[`ICSS show work with the case "duplicate-export-in-multiple-export": warnings 1`] = `Array []`;
4456

45-
exports[`ICSS case empty-export: errors 1`] = `Array []`;
57+
exports[`ICSS show work with the case "empty-export": errors 1`] = `Array []`;
4658

47-
exports[`ICSS case empty-export: locals 1`] = `undefined`;
59+
exports[`ICSS show work with the case "empty-export": module 1`] = `
60+
"// Imports
61+
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
62+
exports = module.exports = ___CSS_LOADER_API_IMPORT___(false);
63+
// Module
64+
exports.push([module.id, \\"\\\\n\\", \\"\\"]);
65+
"
66+
`;
4867

49-
exports[`ICSS case empty-export: module (evaluated) 1`] = `
68+
exports[`ICSS show work with the case "empty-export": result 1`] = `
5069
Array [
5170
Array [
52-
1,
71+
"./icss/tests-cases/empty-export/source.css",
5372
"
5473
",
5574
"",
5675
],
5776
]
5877
`;
5978

60-
exports[`ICSS case empty-export: warnings 1`] = `Array []`;
79+
exports[`ICSS show work with the case "empty-export": warnings 1`] = `Array []`;
6180

62-
exports[`ICSS case empty-import: errors 1`] = `Array []`;
81+
exports[`ICSS show work with the case "empty-import": errors 1`] = `Array []`;
6382

64-
exports[`ICSS case empty-import: locals 1`] = `undefined`;
83+
exports[`ICSS show work with the case "empty-import": module 1`] = `
84+
"// Imports
85+
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
86+
exports = module.exports = ___CSS_LOADER_API_IMPORT___(false);
87+
// Module
88+
exports.push([module.id, \\"\\\\n\\", \\"\\"]);
89+
"
90+
`;
6591

66-
exports[`ICSS case empty-import: module (evaluated) 1`] = `
92+
exports[`ICSS show work with the case "empty-import": result 1`] = `
6793
Array [
6894
Array [
69-
1,
95+
"./icss/tests-cases/empty-import/source.css",
7096
"
7197
",
7298
"",
7399
],
74100
]
75101
`;
76102

77-
exports[`ICSS case empty-import: warnings 1`] = `Array []`;
103+
exports[`ICSS show work with the case "empty-import": warnings 1`] = `Array []`;
78104

79-
exports[`ICSS case export: errors 1`] = `Array []`;
105+
exports[`ICSS show work with the case "export": errors 1`] = `Array []`;
80106

81-
exports[`ICSS case export: locals 1`] = `
82-
Object {
83-
"_test": "_test",
84-
}
107+
exports[`ICSS show work with the case "export": module 1`] = `
108+
"// Imports
109+
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
110+
exports = module.exports = ___CSS_LOADER_API_IMPORT___(false);
111+
// Module
112+
exports.push([module.id, \\"\\\\n\\", \\"\\"]);
113+
// Exports
114+
exports.locals = {
115+
\\"_test\\": \\"_test\\"
116+
};"
85117
`;
86118

87-
exports[`ICSS case export: module (evaluated) 1`] = `
119+
exports[`ICSS show work with the case "export": result 1`] = `
88120
Array [
89121
Array [
90-
1,
122+
"./icss/tests-cases/export/source.css",
91123
"
92124
",
93125
"",
94126
],
95127
]
96128
`;
97129

98-
exports[`ICSS case export: warnings 1`] = `Array []`;
99-
100-
exports[`ICSS case export-reserved-keywords: errors 1`] = `Array []`;
101-
102-
exports[`ICSS case export-reserved-keywords: locals 1`] = `
103-
Object {
104-
"constructor": "constructor",
105-
"toString": "toString",
106-
}
130+
exports[`ICSS show work with the case "export": warnings 1`] = `Array []`;
131+
132+
exports[`ICSS show work with the case "export-reserved-keywords": errors 1`] = `Array []`;
133+
134+
exports[`ICSS show work with the case "export-reserved-keywords": module 1`] = `
135+
"// Imports
136+
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
137+
exports = module.exports = ___CSS_LOADER_API_IMPORT___(false);
138+
// Module
139+
exports.push([module.id, \\"\\\\n\\", \\"\\"]);
140+
// Exports
141+
exports.locals = {
142+
\\"constructor\\": \\"constructor\\",
143+
\\"toString\\": \\"toString\\"
144+
};"
107145
`;
108146

109-
exports[`ICSS case export-reserved-keywords: module (evaluated) 1`] = `
147+
exports[`ICSS show work with the case "export-reserved-keywords": result 1`] = `
110148
Array [
111149
Array [
112-
1,
150+
"./icss/tests-cases/export-reserved-keywords/source.css",
113151
"
114152
",
115153
"",
116154
],
117155
]
118156
`;
119157

120-
exports[`ICSS case export-reserved-keywords: warnings 1`] = `Array []`;
121-
122-
exports[`ICSS case import: errors 1`] = `Array []`;
123-
124-
exports[`ICSS case import: locals 1`] = `
125-
Object {
126-
"primary-color": "red",
127-
}
158+
exports[`ICSS show work with the case "export-reserved-keywords": warnings 1`] = `Array []`;
159+
160+
exports[`ICSS show work with the case "import": errors 1`] = `Array []`;
161+
162+
exports[`ICSS show work with the case "import": module 1`] = `
163+
"// Imports
164+
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
165+
var ___CSS_LOADER_ICSS_IMPORT_0___ = require(\\"-!../../../../../src/index.js??ref--4!./vars.css\\");
166+
exports = module.exports = ___CSS_LOADER_API_IMPORT___(false);
167+
exports.i(___CSS_LOADER_ICSS_IMPORT_0___);
168+
// Module
169+
exports.push([module.id, \\".className {\\\\n color: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\";\\\\n}\\\\n\\", \\"\\"]);
170+
// Exports
171+
exports.locals = {
172+
\\"primary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\"\\"
173+
};"
128174
`;
129175

130-
exports[`ICSS case import: module (evaluated) 1`] = `
176+
exports[`ICSS show work with the case "import": result 1`] = `
131177
Array [
132178
Array [
133-
2,
179+
"../../src/index.js?!./icss/tests-cases/import/vars.css",
134180
"
135181
",
136182
"",
137183
],
138184
Array [
139-
1,
185+
"./icss/tests-cases/import/source.css",
140186
".className {
141187
color: red;
142188
}
@@ -146,27 +192,35 @@ Array [
146192
]
147193
`;
148194

149-
exports[`ICSS case import: warnings 1`] = `Array []`;
150-
151-
exports[`ICSS case import-reserved-keywords: errors 1`] = `Array []`;
152-
153-
exports[`ICSS case import-reserved-keywords: locals 1`] = `
154-
Object {
155-
"primary-color": "red",
156-
"secondary-color": "block",
157-
}
195+
exports[`ICSS show work with the case "import": warnings 1`] = `Array []`;
196+
197+
exports[`ICSS show work with the case "import-reserved-keywords": errors 1`] = `Array []`;
198+
199+
exports[`ICSS show work with the case "import-reserved-keywords": module 1`] = `
200+
"// Imports
201+
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
202+
var ___CSS_LOADER_ICSS_IMPORT_0___ = require(\\"-!../../../../../src/index.js??ref--4!./vars.css\\");
203+
exports = module.exports = ___CSS_LOADER_API_IMPORT___(false);
204+
exports.i(___CSS_LOADER_ICSS_IMPORT_0___);
205+
// Module
206+
exports.push([module.id, \\".className {\\\\n color: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\";\\\\n display: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"secondary-color\\"] + \\";\\\\n}\\\\n\\", \\"\\"]);
207+
// Exports
208+
exports.locals = {
209+
\\"primary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\"\\",
210+
\\"secondary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"secondary-color\\"] + \\"\\"
211+
};"
158212
`;
159213

160-
exports[`ICSS case import-reserved-keywords: module (evaluated) 1`] = `
214+
exports[`ICSS show work with the case "import-reserved-keywords": result 1`] = `
161215
Array [
162216
Array [
163-
2,
217+
"../../src/index.js?!./icss/tests-cases/import-reserved-keywords/vars.css",
164218
"
165219
",
166220
"",
167221
],
168222
Array [
169-
1,
223+
"./icss/tests-cases/import-reserved-keywords/source.css",
170224
".className {
171225
color: red;
172226
display: block;
@@ -177,51 +231,63 @@ Array [
177231
]
178232
`;
179233

180-
exports[`ICSS case import-reserved-keywords: warnings 1`] = `Array []`;
181-
182-
exports[`ICSS case multiple-export: errors 1`] = `Array []`;
183-
184-
exports[`ICSS case multiple-export: locals 1`] = `
185-
Object {
186-
"_foo": "_bar",
187-
"_test": "_test",
188-
}
234+
exports[`ICSS show work with the case "import-reserved-keywords": warnings 1`] = `Array []`;
235+
236+
exports[`ICSS show work with the case "multiple-export": errors 1`] = `Array []`;
237+
238+
exports[`ICSS show work with the case "multiple-export": module 1`] = `
239+
"// Imports
240+
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
241+
exports = module.exports = ___CSS_LOADER_API_IMPORT___(false);
242+
// Module
243+
exports.push([module.id, \\"\\\\n\\", \\"\\"]);
244+
// Exports
245+
exports.locals = {
246+
\\"_test\\": \\"_test\\",
247+
\\"_foo\\": \\"_bar\\"
248+
};"
189249
`;
190250

191-
exports[`ICSS case multiple-export: module (evaluated) 1`] = `
251+
exports[`ICSS show work with the case "multiple-export": result 1`] = `
192252
Array [
193253
Array [
194-
1,
254+
"./icss/tests-cases/multiple-export/source.css",
195255
"
196256
",
197257
"",
198258
],
199259
]
200260
`;
201261

202-
exports[`ICSS case multiple-export: warnings 1`] = `Array []`;
203-
204-
exports[`ICSS case multiple-keys-values-in-export: errors 1`] = `Array []`;
205-
206-
exports[`ICSS case multiple-keys-values-in-export: locals 1`] = `
207-
Object {
208-
"_test": "_test",
209-
"_test1": "1",
210-
"_test2": "'string'",
211-
"_test3": "1px 2px 3px",
212-
"_test4": "1px 2px 3px, 1px 2px 3px",
213-
}
262+
exports[`ICSS show work with the case "multiple-export": warnings 1`] = `Array []`;
263+
264+
exports[`ICSS show work with the case "multiple-keys-values-in-export": errors 1`] = `Array []`;
265+
266+
exports[`ICSS show work with the case "multiple-keys-values-in-export": module 1`] = `
267+
"// Imports
268+
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
269+
exports = module.exports = ___CSS_LOADER_API_IMPORT___(false);
270+
// Module
271+
exports.push([module.id, \\"\\\\n\\", \\"\\"]);
272+
// Exports
273+
exports.locals = {
274+
\\"_test\\": \\"_test\\",
275+
\\"_test1\\": \\"1\\",
276+
\\"_test2\\": \\"'string'\\",
277+
\\"_test3\\": \\"1px 2px 3px\\",
278+
\\"_test4\\": \\"1px 2px 3px, 1px 2px 3px\\"
279+
};"
214280
`;
215281

216-
exports[`ICSS case multiple-keys-values-in-export: module (evaluated) 1`] = `
282+
exports[`ICSS show work with the case "multiple-keys-values-in-export": result 1`] = `
217283
Array [
218284
Array [
219-
1,
285+
"./icss/tests-cases/multiple-keys-values-in-export/source.css",
220286
"
221287
",
222288
"",
223289
],
224290
]
225291
`;
226292

227-
exports[`ICSS case multiple-keys-values-in-export: warnings 1`] = `Array []`;
293+
exports[`ICSS show work with the case "multiple-keys-values-in-export": warnings 1`] = `Array []`;

0 commit comments

Comments
 (0)