forked from webpack-contrib/css-loader
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaliasTest.js
57 lines (50 loc) · 1.8 KB
/
aliasTest.js
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
/*globals describe */
var test = require("./helpers").test;
describe("alias", function() {
var css = ".className { background: url(./path/to/file.png); }";
var exports = {
without: [
[1, ".className { background: url({./path/to/file.png}); }", ""]
],
onlyModule: [
[1, ".className { background: url({module/file.png}); }", ""]
],
exactMatch: [
[1, ".className { background: url({module/file.png}); }", ""]
],
notExactMatch: [
[1, ".className { background: url({./path/to/file.png}); }", ""]
]
};
function aliasOptions(alias) {
return { query: { alias: alias }}
}
test("without", css, exports.without);
test("onlyModule", css, exports.onlyModule, aliasOptions({ "./path/to": "module" }));
test("exactMatch", css, exports.exactMatch, aliasOptions({ "./path/to/file.png$": "module/file.png" }));
test("notExactMatch", css, exports.notExactMatch, aliasOptions({ "./path/to/file.jpg$": "module/file.jpg" }));
});
describe("alias starting with /", function() {
var css = ".className { background: url(/path/to/file.png); }";
var exports = {
without: [
[1, ".className { background: url(/path/to/file.png); }", ""]
],
onlyModule: [
[1, ".className { background: url({module/file.png}); }", ""]
],
exactMatch: [
[1, ".className { background: url({module/file.png}); }", ""]
],
notExactMatch: [
[1, ".className { background: url(/path/to/file.png); }", ""]
]
};
function aliasOptions(alias) {
return { query: { alias: alias }}
}
test("without", css, exports.without);
test("onlyModule", css, exports.onlyModule, aliasOptions({ "/path/to": "module" }));
test("exactMatch", css, exports.exactMatch, aliasOptions({ "/path/to/file.png$": "module/file.png" }));
test("notExactMatch", css, exports.notExactMatch, aliasOptions({ "/path/to/file.jpg$": "module/file.jpg" }));
});