@@ -12,9 +12,7 @@ const getWarnings = result => result.warnings().map(warning => warning.text);
12
12
const run = ( { fixture, expected, warnings = [ ] } ) =>
13
13
compile ( fixture ) . then ( result => {
14
14
expect ( getWarnings ( result ) ) . toEqual ( warnings ) ;
15
- if ( expected ) {
16
- expect ( result . css . trim ( ) ) . toEqual ( strip ( expected ) ) ;
17
- }
15
+ expect ( result . css . trim ( ) ) . toEqual ( strip ( expected ) ) ;
18
16
} ) ;
19
17
20
18
test ( "export value" , ( ) => {
@@ -38,6 +36,7 @@ test("warn when there is no semicolon between lines", () => {
38
36
@value red blue
39
37
@value green yellow
40
38
` ,
39
+ expected : "" ,
41
40
warnings : [ `Invalid value definition "red blue\n@value green yellow"` ]
42
41
} ) ;
43
42
} ) ;
@@ -124,6 +123,31 @@ test("import external values with aliases", () => {
124
123
} ) ;
125
124
} ) ;
126
125
126
+ test ( "import multiple values grouped with parentheses on multiple lines" , ( ) => {
127
+ return run ( {
128
+ fixture : `
129
+ @value (
130
+ blue,
131
+ red
132
+ ) from "path";
133
+ .foo { color: red; }
134
+ .bar { color: blue }
135
+ ` ,
136
+ expected : `
137
+ :import('path') {
138
+ __value__blue__0: blue;
139
+ __value__red__1: red;
140
+ }
141
+ :export {
142
+ blue: __value__blue__0;
143
+ red: __value__red__1;
144
+ }
145
+ .foo { color: __value__red__1; }
146
+ .bar { color: __value__blue__0 }
147
+ `
148
+ } ) ;
149
+ } ) ;
150
+
127
151
test ( "warn on unexpected value defintion or import" , ( ) => {
128
152
return run ( {
129
153
fixture : `
@@ -136,7 +160,9 @@ test("warn on unexpected value defintion or import", () => {
136
160
@value red as 'blue' from 'path';
137
161
@value 'red' as blue from 'path';
138
162
@value red 'as' blue from 'path';
163
+ @value fn(red, blue) from 'path';
139
164
` ,
165
+ expected : "" ,
140
166
warnings : [
141
167
`Invalid value definition "red"` ,
142
168
`Invalid value definition "red:"` ,
@@ -146,7 +172,8 @@ test("warn on unexpected value defintion or import", () => {
146
172
`Invalid value definition "red from 'path' token"` ,
147
173
`Invalid value definition "red as 'blue' from 'path'"` ,
148
174
`Invalid value definition "'red' as blue from 'path'"` ,
149
- `Invalid value definition "red 'as' blue from 'path'"`
175
+ `Invalid value definition "red 'as' blue from 'path'"` ,
176
+ `Invalid value definition "fn(red, blue) from 'path'"`
150
177
]
151
178
} ) ;
152
179
} ) ;
@@ -237,31 +264,6 @@ test("allow all colour types", () => {
237
264
} ) ;
238
265
} ) ;
239
266
240
- test ( "import multiple values grouped with parentheses on multiple lines" , ( ) => {
241
- return run ( {
242
- fixture : `
243
- @value (
244
- blue,
245
- red
246
- ) from "path";
247
- .foo { color: red; }
248
- .bar { color: blue }
249
- ` ,
250
- expected : `
251
- :import('path') {
252
- __value__blue__0: blue;
253
- __value__red__1: red;
254
- }
255
- :export {
256
- blue: __value__blue__0;
257
- red: __value__red__1;
258
- }
259
- .foo { color: __value__red__1; }
260
- .bar { color: __value__blue__0 }
261
- `
262
- } ) ;
263
- } ) ;
264
-
265
267
test ( "allow definitions with commas in them" , ( ) => {
266
268
return run ( {
267
269
fixture : `
0 commit comments