-
-
Notifications
You must be signed in to change notification settings - Fork 608
/
Copy pathvaluesTest.js
120 lines (117 loc) · 2.72 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*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;
})()
}
);
testLocal("should import values contain comma",
"@value color from './file1'; @value shadow: 0 0 color,0 0 color; .ghi { box-shadow: shadow; }", [
[ 2, "", "" ],
[ 1, ".ghi { box-shadow: 0 0 red,0 0 red; }", "" ]
], {
color: "red",
shadow: "0 0 red,0 0 red"
}, "", {
"./file1": (function() {
var a = [[2, "", ""]];
a.locals = {
color: "red",
};
return a;
})()
}
);
testLocal("should import values contain comma and space before comma",
"@value color from './file1'; @value shadow: 0 0 color ,0 0 color; .ghi { box-shadow: shadow; }", [
[ 2, "", "" ],
[ 1, ".ghi { box-shadow: 0 0 red ,0 0 red; }", "" ]
], {
color: "red",
shadow: "0 0 red ,0 0 red"
}, "", {
"./file1": (function() {
var a = [[2, "", ""]];
a.locals = {
color: "red",
};
return a;
})()
}
);
testLocal("should import values contain tralling comma and space after comma",
"@value color from './file1'; @value shadow: 0 0 color, 0 0 color; .ghi { box-shadow: shadow; }", [
[ 2, "", "" ],
[ 1, ".ghi { box-shadow: 0 0 red, 0 0 red; }", "" ]
], {
color: "red",
shadow: "0 0 red, 0 0 red"
}, "", {
"./file1": (function() {
var a = [[2, "", ""]];
a.locals = {
color: "red",
};
return a;
})()
}
);
});