@@ -12,9 +12,7 @@ const getWarnings = result => result.warnings().map(warning => warning.text);
1212const run = ( { fixture, expected, warnings = [ ] } ) =>
1313 compile ( fixture ) . then ( result => {
1414 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 ) ) ;
1816 } ) ;
1917
2018test ( "export value" , ( ) => {
@@ -38,6 +36,7 @@ test("warn when there is no semicolon between lines", () => {
3836 @value red blue
3937 @value green yellow
4038 ` ,
39+ expected : "" ,
4140 warnings : [ `Invalid value definition "red blue\n@value green yellow"` ]
4241 } ) ;
4342} ) ;
@@ -124,6 +123,31 @@ test("import external values with aliases", () => {
124123 } ) ;
125124} ) ;
126125
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+
127151test ( "warn on unexpected value defintion or import" , ( ) => {
128152 return run ( {
129153 fixture : `
@@ -136,7 +160,9 @@ test("warn on unexpected value defintion or import", () => {
136160 @value red as 'blue' from 'path';
137161 @value 'red' as blue from 'path';
138162 @value red 'as' blue from 'path';
163+ @value fn(red, blue) from 'path';
139164 ` ,
165+ expected : "" ,
140166 warnings : [
141167 `Invalid value definition "red"` ,
142168 `Invalid value definition "red:"` ,
@@ -146,7 +172,8 @@ test("warn on unexpected value defintion or import", () => {
146172 `Invalid value definition "red from 'path' token"` ,
147173 `Invalid value definition "red as 'blue' from 'path'"` ,
148174 `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'"`
150177 ]
151178 } ) ;
152179} ) ;
@@ -237,31 +264,6 @@ test("allow all colour types", () => {
237264 } ) ;
238265} ) ;
239266
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-
265267test ( "allow definitions with commas in them" , ( ) => {
266268 return run ( {
267269 fixture : `
0 commit comments