This repository was archived by the owner on Dec 17, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 188
Expand file tree
/
Copy pathstringifyUseEntries.test.js
More file actions
72 lines (67 loc) · 1.51 KB
/
stringifyUseEntries.test.js
File metadata and controls
72 lines (67 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"use strict";
const loaderUtils = require("../");
function ExpectedError(regex) {
this.regex = regex;
}
ExpectedError.prototype.matches = function (err) {
return this.regex.test(err.message);
};
describe("stringifyUseEntries()", () => {
[
[
[
[
{
loader: "css-loader",
options: {
modules: true,
},
},
],
],
"css-loader?{'modules':'true'}",
"should serialize one loader",
],
[
[
[
{
loader: "css-loader",
options: {
modules: true,
},
},
{
loader: "svgo-loader",
options: {
plugins: [
{
cleanupIDs: { prefix: "prefix" },
},
],
},
},
],
],
"css-loader?{'modules':'true'}!svgo-loader?{'plugins':[{'cleanupIDs':{'prefix':'prefix'}}]}",
"should serialize multiple loaders",
],
].forEach((test) => {
it(test[2], () => {
const expected = test[1];
try {
const request = loaderUtils.stringifyUseEntries.apply(
loaderUtils,
test[0]
);
expect(request).toBe(expected);
} catch (e) {
if (expected instanceof ExpectedError) {
expect(expected.matches(e)).toBe(true);
} else {
throw new Error("should not have thrown an error: " + e.message);
}
}
});
});
});