forked from unocss/unocss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
preset-wind.test.ts
95 lines (85 loc) · 2.18 KB
/
preset-wind.test.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import { createGenerator, escapeSelector } from '@unocss/core'
import presetWind from '@unocss/preset-wind'
import { describe, expect, test } from 'vitest'
import { presetWindNonTargets, presetWindTargets } from './assets/preset-wind-targets'
const uno = createGenerator({
presets: [
presetWind({
dark: 'media',
}),
],
theme: {
colors: {
custom: {
a: 'var(--custom)',
b: 'rgba(var(--custom), %alpha)',
},
},
data: {
dropdown: 'data-bs-toggle="dropdown"',
},
container: {
center: true,
padding: {
'DEFAULT': '1rem',
'sm': '2rem',
'lg': '4rem',
'xl': '5rem',
'2xl': '6rem',
},
},
},
})
describe('preset-wind', () => {
test('targets', async () => {
const targets = presetWindTargets
const code = targets.join(' ')
const { css } = await uno.generate(code)
const { css: css2 } = await uno.generate(code)
const unmatched = []
for (const i of targets) {
if (!css.includes(escapeSelector(i)))
unmatched.push(i)
}
expect(unmatched).toEqual([])
expect(css).toMatchSnapshot()
expect(css).toEqual(css2)
})
test('non-targets', async () => {
const { matched } = await uno.generate(new Set(presetWindNonTargets), { preflights: false })
expect([...matched]).toEqual([])
})
test('containers', async () => {
const targets = [
'container',
'md:container',
'lg:container',
]
const nonTargets = [
'__container',
]
const { css, matched } = await uno.generate(new Set([...targets, ...nonTargets]), { preflights: false })
expect(matched).toEqual(new Set(targets))
expect(css).toMatchSnapshot()
})
test('centered containers', async () => {
const uno = createGenerator({
presets: [
presetWind(),
],
theme: {
container: {
center: true,
},
},
})
const targets = [
'container',
'md:container',
'lg:container',
]
const { css, matched } = await uno.generate(new Set(targets), { preflights: false })
expect(matched).toEqual(new Set(targets))
expect(css).toMatchSnapshot()
})
})