Skip to content

Commit 26acdc8

Browse files
committed
fix: Make remaining skipped tests pass with optimization.
1 parent 5b7758f commit 26acdc8

File tree

1 file changed

+31
-33
lines changed

1 file changed

+31
-33
lines changed

packages/jsx-analyzer/test/transformer/transformer-test.ts

+31-33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { assert } from 'chai';
2-
import { suite, test, skip } from 'mocha-typescript';
2+
import { suite, test } from 'mocha-typescript';
33
import * as babel from 'babel-core';
44
import { StyleMapping, PluginOptionsReader, CssBlockOptions, BlockCompiler } from 'css-blocks';
55
import * as postcss from 'postcss';
@@ -239,7 +239,6 @@ export class Test {
239239
});
240240
}
241241

242-
@skip
243242
@test 'States with dynamic sub-states are transformed when only a single sub-state exists'(){
244243
mock({
245244
'bar.block.css': `
@@ -260,36 +259,34 @@ export class Test {
260259
let leSigh = true;
261260
262261
let style = objstr({
263-
[bar.pretty]: true,
262+
[bar.pretty]: leSigh,
264263
[bar.pretty.bool()]: true,
265-
[bar.pretty.color(dynamic)]: leSigh
264+
[bar.pretty.color(dynamic)]: true
266265
});
267266
268267
<div class={bar.root}><div class={style}></div></div>;
269268
`;
270269

271-
return parse(code).then((analysis: MetaAnalysis) => {
272-
270+
return parse(code, 'test.tsx').then((analysis: MetaAnalysis) => {
273271
return transform(code, analysis.getAnalysis(0)).then(res => {
274272
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+
`)
287285
);
288286
});
289287
});
290288
}
291289

292-
@skip
293290
@test 'States with dynamic sub-states containing complex expression are transformed to the simplest possible output'(){
294291
mock({
295292
'bar.block.css': `
@@ -309,31 +306,32 @@ export class Test {
309306
import objstr from 'obj-str';
310307
311308
let dynamic = 'yellow';
309+
function conditional() {
310+
return true;
311+
}
312312
313313
let style = objstr({
314314
[bar.pretty]: true,
315-
[bar.pretty.color(\`\${dynamic}Color\`)]: true
315+
[bar.pretty.color(\`\${dynamic}Color\`)]: conditional()
316316
});
317317
318318
<div class={bar.root}><div class={style}></div></div>;
319319
`;
320320

321-
return parse(code).then((analysis: MetaAnalysis) => {
321+
return parse(code, 'test.jsx').then((analysis: MetaAnalysis) => {
322322

323323
return transform(code, analysis.getAnalysis(0)).then(res => {
324324
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>;`)
337335
);
338336
});
339337
});

0 commit comments

Comments
 (0)