Skip to content

Commit 8c5c317

Browse files
committed
test: unit tests of css
1 parent 94f1227 commit 8c5c317

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## index.css
2+
3+
```css
4+
body { color: red }
5+
6+
```
7+
## index.js
8+
9+
```js
10+
export { };
11+
```
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## index.js
2+
3+
```js
4+
import "./style.js";
5+
6+
export { };
7+
```
8+
## style-CDacwehR.css
9+
10+
```css
11+
body { color: red }
12+
13+
```
14+
## style.js
15+
16+
```js
17+
export { };
18+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## style.css
2+
3+
```css
4+
body { color: red }
5+
6+
```
7+
## style.js
8+
9+
```js
10+
export { };
11+
```

tests/css.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { describe, expect, test } from 'vitest'
2+
import { testBuild } from './utils'
3+
4+
describe('css', () => {
5+
test('basic', async (context) => {
6+
const { outputFiles } = await testBuild({
7+
context,
8+
files: {
9+
'index.ts': `import './style.css'`,
10+
'style.css': `body { color: red }`,
11+
},
12+
})
13+
expect(outputFiles).toEqual(['index.css', 'index.js'])
14+
})
15+
16+
test.fails('unbundle', async (context) => {
17+
const { outputFiles } = await testBuild({
18+
context,
19+
files: {
20+
'index.ts': `import './style.css'`,
21+
'style.css': `body { color: red }`,
22+
},
23+
options: {
24+
unbundle: true,
25+
},
26+
})
27+
expect(outputFiles).toEqual(['index.js', 'style.js', 'style.css'])
28+
})
29+
30+
test.fails('with dts', async (context) => {
31+
const { outputFiles } = await testBuild({
32+
context,
33+
files: {
34+
'style.css': `body { color: red }`,
35+
},
36+
options: {
37+
entry: ['style.css'],
38+
dts: true,
39+
},
40+
})
41+
expect(outputFiles).toEqual(['style.css', 'style.js', 'style.d.ts'])
42+
})
43+
})

0 commit comments

Comments
 (0)