1
1
import { assert } from 'chai' ;
2
- import { suite , test , skip } from 'mocha-typescript' ;
2
+ import { suite , test } from 'mocha-typescript' ;
3
3
import * as babel from 'babel-core' ;
4
4
import { StyleMapping , PluginOptionsReader , CssBlockOptions , BlockCompiler } from 'css-blocks' ;
5
5
import * as postcss from 'postcss' ;
@@ -239,7 +239,6 @@ export class Test {
239
239
} ) ;
240
240
}
241
241
242
- @skip
243
242
@test 'States with dynamic sub-states are transformed when only a single sub-state exists' ( ) {
244
243
mock ( {
245
244
'bar.block.css' : `
@@ -260,36 +259,34 @@ export class Test {
260
259
let leSigh = true;
261
260
262
261
let style = objstr({
263
- [bar.pretty]: true ,
262
+ [bar.pretty]: leSigh ,
264
263
[bar.pretty.bool()]: true,
265
- [bar.pretty.color(dynamic)]: leSigh
264
+ [bar.pretty.color(dynamic)]: true
266
265
});
267
266
268
267
<div class={bar.root}><div class={style}></div></div>;
269
268
` ;
270
269
271
- return parse ( code ) . then ( ( analysis : MetaAnalysis ) => {
272
-
270
+ return parse ( code , 'test.tsx' ) . then ( ( analysis : MetaAnalysis ) => {
273
271
return transform ( code , analysis . getAnalysis ( 0 ) ) . then ( res => {
274
272
assert . equal ( minify ( res . jsx . code ! ) , minify ( `
275
- import objstr from 'obj-str' ;
276
-
277
- let dynamic = ' yellow' ;
278
- let leSigh = true;
279
-
280
- let style = objstr({
281
- 'bar__pretty': true ,
282
- 'bar__pretty--bool': true,
283
- 'bar__pretty--color-yellow': dynamic === 'yellow' && leSigh
284
- });
285
-
286
- <div class="bar"><div class={style}></div></div>; ` )
273
+ import { c as c$$ } from "@css-blocks/jsx" ;
274
+ import objstr from "obj-str";
275
+ let dynamic = " yellow" ;
276
+ let leSigh = true;
277
+ <div class="b">
278
+ <div
279
+ class={c$$([ 3, 2, 0, leSigh, 1, 0, 0, 1, 1, 0, 1, 1, 5, 1, 0, 1 ,
280
+ 0, dynamic, "yellow", 1, 2, "c", -2, 2, 0, 1, "d", 2
281
+ ])}
282
+ />
283
+ </div>;
284
+ ` )
287
285
) ;
288
286
} ) ;
289
287
} ) ;
290
288
}
291
289
292
- @skip
293
290
@test 'States with dynamic sub-states containing complex expression are transformed to the simplest possible output' ( ) {
294
291
mock ( {
295
292
'bar.block.css' : `
@@ -309,31 +306,32 @@ export class Test {
309
306
import objstr from 'obj-str';
310
307
311
308
let dynamic = 'yellow';
309
+ function conditional() {
310
+ return true;
311
+ }
312
312
313
313
let style = objstr({
314
314
[bar.pretty]: true,
315
- [bar.pretty.color(\`\${dynamic}Color\`)]: true
315
+ [bar.pretty.color(\`\${dynamic}Color\`)]: conditional()
316
316
});
317
317
318
318
<div class={bar.root}><div class={style}></div></div>;
319
319
` ;
320
320
321
- return parse ( code ) . then ( ( analysis : MetaAnalysis ) => {
321
+ return parse ( code , 'test.jsx' ) . then ( ( analysis : MetaAnalysis ) => {
322
322
323
323
return transform ( code , analysis . getAnalysis ( 0 ) ) . then ( res => {
324
324
assert . equal ( minify ( res . jsx . code ! ) , minify ( `
325
- import objstr from 'obj-str';
326
-
327
- let dynamic = 'yellow';
328
-
329
- const _condition = \`\${dynamic}Color\`;
330
- let style = objstr({
331
- 'bar__pretty': true,
332
- 'bar__pretty--color-yellowColor': _condition === 'yellowColor',
333
- 'bar__pretty--color-greenColor': _condition === 'greenColor'
334
- });
335
-
336
- <div class="bar"><div class={style}></div></div>;` )
325
+ import { c as c$$ } from "@css-blocks/jsx";
326
+ import objstr from "obj-str";
327
+ let dynamic = "yellow";
328
+ function conditional() {
329
+ return true;
330
+ }
331
+ <div class="a">
332
+ <div class={c$$("b", [1,2,4,2,1,conditional() && \`\${dynamic}Color\`,
333
+ "yellowColor",1,1,"greenColor",1,0,"d",0,"c",1])} />
334
+ </div>;` )
337
335
) ;
338
336
} ) ;
339
337
} ) ;
0 commit comments