/
process-css.spec.ts
37 lines (32 loc) · 1.05 KB
/
process-css.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { describe, expect, test } from 'vitest'
import { useRemoveStyles } from './utils'
describe('process only css, not module css', () => {
useRemoveStyles()
test('apply css', async () => {
await import('../src/App.css')
const element = document.createElement('div')
element.className = 'main'
const computed = window.getComputedStyle(element)
expect(computed.display).toBe('flex')
expect(element).toMatchInlineSnapshot(`
<div
class="main"
/>
`)
})
test('module is not processed', async () => {
const { default: styles } = await import('../src/App.module.css')
expect(styles.module).toBe('_module_6dc87e')
expect(styles.someRandomValue).toBe('_someRandomValue_6dc87e')
const element = document.createElement('div')
element.className = '_module_6dc87e'
const computed = window.getComputedStyle(element)
expect(computed.display).toBe('block')
expect(computed.width).toBe('')
expect(element).toMatchInlineSnapshot(`
<div
class="_module_6dc87e"
/>
`)
})
})