-
-
Notifications
You must be signed in to change notification settings - Fork 608
/
Copy pathvaluesTest.js
69 lines (66 loc) · 1.44 KB
/
valuesTest.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
58
59
60
61
62
63
64
65
66
67
68
69
/*globals describe */
var testLocals = require("./helpers").testLocals;
var test = require("./helpers").test;
function testLocal(name, input, result, localsResult, query, modules) {
result.locals = localsResult;
test(name, input, result, query, modules);
}
describe("values", function() {
testLocals("should export values",
"@value def: red; @value ghi: 1px solid black",
{
def: "red",
ghi: "1px solid black"
},
""
);
testLocals("should export values and locals",
"@value def: red; .ghi { color: def; }",
{
def: "red",
ghi: "_ghi"
},
"?modules&localIdentName=_[local]"
);
testLocal("should import values from other module",
"@value def from './file'; .ghi { color: def; }", [
[ 2, "", "" ],
[ 1, ".ghi { color: red; }", "" ]
], {
def: "red"
}, "", {
"./file": (function() {
var a = [[2, "", ""]];
a.locals = {
def: "red"
};
return a;
})()
}
);
testLocal("should import values with renaming",
"@value def as aaa from './file1'; @value def as bbb from './file2'; .ghi { background: aaa, bbb, def; }", [
[ 2, "", "" ],
[ 3, "", "" ],
[ 1, ".ghi { background: red, green, def; }", "" ]
], {
aaa: "red",
bbb: "green"
}, "", {
"./file1": (function() {
var a = [[2, "", ""]];
a.locals = {
def: "red"
};
return a;
})(),
"./file2": (function() {
var a = [[3, "", ""]];
a.locals = {
def: "green"
};
return a;
})()
}
);
});