Skip to content

Commit 6bba6fd

Browse files
committed
refactor tests
1 parent bf25c15 commit 6bba6fd

8 files changed

+39
-36
lines changed

test/_tape.js

+21-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,32 @@ postcssTape(plugin)({
66
message: 'supports basic usage',
77
options: {
88
functions: {
9-
'--shadow': (shadowColor) =>
10-
`2px 2px ${shadowColor ? shadowColor : 'var(--shadow-color, black)'}`,
9+
'--shadow': (shadowColor = 'var(--shadow-color, black)') =>
10+
`2px 2px ${shadowColor}`,
1111
'--negative': (value) => `calc(-1 * ${value})`,
1212
'--repeat': (a, b) => `repeat(${a}, ${b})`,
1313
'--comma-separated-list-of-component-values': () => '10px, 20px',
1414
},
1515
},
16+
},
17+
'syntax-errors': {
18+
message: 'warn syntax errors',
19+
options: {
20+
functions: {
21+
'--negative': (value) => `calc(-1 * ${value})`,
22+
},
23+
},
24+
warnings: 3,
25+
},
26+
'function-errors': {
27+
message: 'warn function errors',
28+
options: {
29+
functions: {
30+
'--error': () => {
31+
throw new Error('function error');
32+
},
33+
},
34+
},
1635
warnings: 3,
1736
},
1837
});

test/basic.css

-7
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,3 @@
1919
/* Separated list */
2020
--list: --comma-separated-list-of-component-values();
2121
}
22-
23-
.invalid {
24-
/* Syntax checking */
25-
font-size: --negative(,);
26-
font-size: --negative(10px,);
27-
font-size: --negative(,10px);
28-
}

test/basic.expect.css

-7
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,3 @@
1919
/* Separated list */
2020
--list: 10px, 20px;
2121
}
22-
23-
.invalid {
24-
/* Syntax checking */
25-
font-size: --negative(,);
26-
font-size: --negative(10px,);
27-
font-size: --negative(,10px);
28-
}

test/function-errors.css

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.invalid {
2+
margin: --error();
3+
margin: --error() --error();
4+
}

test/function-errors.expect.css

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.invalid {
2+
margin: --error();
3+
margin: --error() --error();
4+
}

test/index.js

-20
This file was deleted.

test/syntax-errors.css

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.invalid {
2+
font-size: --negative(,);
3+
font-size: --negative(10px,);
4+
font-size: --negative(,10px);
5+
}

test/syntax-errors.expect.css

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.invalid {
2+
font-size: --negative(,);
3+
font-size: --negative(10px,);
4+
font-size: --negative(,10px);
5+
}

0 commit comments

Comments
 (0)