Skip to content

Commit 711a7ee

Browse files
committed
fix invalid test #12
1 parent 9e3e2a2 commit 711a7ee

File tree

5 files changed

+29
-26
lines changed

5 files changed

+29
-26
lines changed

dist/index-umd-web.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4667,7 +4667,8 @@
46674667
}
46684668

46694669
function expand(ast) {
4670-
if (!['AstRule', 'AstRuleStyleSheet', 'AstAtRule'].includes(ast.typ)) {
4670+
//
4671+
if (!['Rule', 'StyleSheet', 'AtRule'].includes(ast.typ)) {
46714672
return ast;
46724673
}
46734674
if ('Rule' == ast.typ) {

dist/index.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4665,7 +4665,8 @@ function* walkValues(values, parent) {
46654665
}
46664666

46674667
function expand(ast) {
4668-
if (!['AstRule', 'AstRuleStyleSheet', 'AstAtRule'].includes(ast.typ)) {
4668+
//
4669+
if (!['Rule', 'StyleSheet', 'AtRule'].includes(ast.typ)) {
46694670
return ast;
46704671
}
46714672
if ('Rule' == ast.typ) {

dist/lib/ast/expand.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import '../renderer/utils/color.js';
55
import { walkValues } from './walk.js';
66

77
function expand(ast) {
8-
if (!['AstRule', 'AstRuleStyleSheet', 'AstAtRule'].includes(ast.typ)) {
8+
//
9+
if (!['Rule', 'StyleSheet', 'AtRule'].includes(ast.typ)) {
910
return ast;
1011
}
1112
if ('Rule' == ast.typ) {

src/lib/ast/expand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {walkValues} from "./walk";
55
import {renderToken} from "../renderer";
66

77
export function expand(ast: AstNode): AstNode {
8-
9-
if (!['AstRule', 'AstRuleStyleSheet', 'AstAtRule'].includes(ast.typ)) {
8+
//
9+
if (!['Rule', 'StyleSheet', 'AtRule'].includes(ast.typ)) {
1010

1111
return ast;
1212
}

test/specs/expand.spec.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* generate from test/specs/nesting.spec.ts */
22
import {expect as f} from '../../node_modules/@esm-bundle/chai/esm/chai.js';
3-
import {transform, render, expand} from '../../dist/node/index.js';
3+
import {parse, render} from '../../dist/node/index.js';
44

55
describe('flatten nested css rules', function () {
66
it('flatten #1', function () {
@@ -11,9 +11,9 @@ describe('flatten nested css rules', function () {
1111
&Bar { color: red; }
1212
}
1313
`;
14-
return transform(nesting1, {
14+
return parse(nesting1, {
1515
minify: true, nestingRules: true
16-
}).then((result) => f(render(expand(result.ast), {minify: false}).code).equals(`.foo {
16+
}).then((result) => f(render(result.ast, {minify: false, expandNestingRules: true}).code).equals(`.foo {
1717
color: blue
1818
}
1919
Bar.foo {
@@ -35,9 +35,9 @@ Bar.foo {
3535
}
3636
}
3737
`;
38-
return transform(nesting1, {
38+
return parse(nesting1, {
3939
minify: true, nestingRules: true
40-
}).then((result) => f(render(expand(result.ast), {minify: false}).code).equals(`.header {
40+
}).then((result) => f(render(result.ast, {minify: false, expandNestingRules: true}).code).equals(`.header {
4141
background-color: blue
4242
}
4343
.header p {
@@ -60,9 +60,9 @@ Bar.foo {
6060
}
6161
}
6262
`;
63-
return transform(nesting1, {
63+
return parse(nesting1, {
6464
minify: true, nestingRules: true
65-
}).then((result) => f(render(expand(result.ast), {minify: false}).code).equals(`.foo {
65+
}).then((result) => f(render(result.ast, {minify: false, expandNestingRules: true}).code).equals(`.foo {
6666
display: grid
6767
}
6868
@media (orientation:landscape) {
@@ -82,9 +82,9 @@ Bar.foo {
8282
}
8383
}
8484
`;
85-
return transform(nesting1, {
85+
return parse(nesting1, {
8686
minify: true, nestingRules: true
87-
}).then((result) => f(render(expand(result.ast), {minify: false}).code).equals(`.foo {
87+
}).then((result) => f(render(result.ast, {minify: false, expandNestingRules: true}).code).equals(`.foo {
8888
display: grid
8989
}
9090
@media (orientation:landscape) {
@@ -108,9 +108,9 @@ Bar.foo {
108108
}
109109
}
110110
`;
111-
return transform(nesting1, {
111+
return parse(nesting1, {
112112
minify: true, nestingRules: true
113-
}).then((result) => f(render(expand(result.ast), {minify: false}).code).equals(`.foo {
113+
}).then((result) => f(render(result.ast, {minify: false, expandNestingRules: true}).code).equals(`.foo {
114114
display: grid
115115
}
116116
@media (orientation:landscape) {
@@ -139,9 +139,9 @@ html {
139139
}
140140
}
141141
`;
142-
return transform(nesting1, {
142+
return parse(nesting1, {
143143
minify: true, nestingRules: true
144-
}).then((result) => f(render(expand(result.ast), {minify: false}).code).equals(`@layer base {
144+
}).then((result) => f(render(result.ast, {minify: false, expandNestingRules: true}).code).equals(`@layer base {
145145
html {
146146
block-size: 100%
147147
}
@@ -167,9 +167,9 @@ html {
167167
}
168168
}
169169
`;
170-
return transform(nesting1, {
170+
return parse(nesting1, {
171171
minify: true, nestingRules: true
172-
}).then((result) => f(render(expand(result.ast), {minify: false}).code).equals(`@layer base {
172+
}).then((result) => f(render(result.ast, {minify: false, expandNestingRules: true}).code).equals(`@layer base {
173173
html {
174174
block-size: 100%
175175
}
@@ -194,9 +194,9 @@ html {
194194
}
195195
}
196196
`;
197-
return transform(nesting1, {
197+
return parse(nesting1, {
198198
minify: true, nestingRules: true
199-
}).then((result) => f(render(expand(result.ast), {minify: false}).code).equals(`.card {
199+
}).then((result) => f(render(result.ast, {minify: false, expandNestingRules: true}).code).equals(`.card {
200200
inline-size: 40ch;
201201
aspect-ratio: 3/4
202202
}
@@ -214,9 +214,9 @@ html {
214214
&& { padding: 2ch; }
215215
}
216216
`;
217-
return transform(nesting1, {
217+
return parse(nesting1, {
218218
minify: true, nestingRules: true
219-
}).then((result) => f(render(expand(result.ast), {minify: false}).code).equals(`.foo {
219+
}).then((result) => f(render(result.ast, {minify: false, expandNestingRules: true}).code).equals(`.foo {
220220
color: blue
221221
}
222222
.foo.foo {
@@ -238,9 +238,9 @@ html {
238238
}
239239
}
240240
`;
241-
return transform(nesting1, {
241+
return parse(nesting1, {
242242
minify: true, nestingRules: true
243-
}).then((result) => f(render(expand(result.ast), {minify: false}).code).equals(`@scope (.card) to (>header) {
243+
}).then((result) => f(render(result.ast, {minify: false, expandNestingRules: true}).code).equals(`@scope (.card) to (>header) {
244244
:scope {
245245
inline-size: 40ch;
246246
aspect-ratio: 3/4

0 commit comments

Comments
 (0)