forked from unocss/unocss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variant-group.test.ts
55 lines (45 loc) · 1.71 KB
/
variant-group.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
import { expandVariantGroup } from '@unocss/core'
import { describe, expect, test } from 'vitest'
describe('variant-group', () => {
test('basic', async () => {
expect(expandVariantGroup('')).toEqual('')
expect(expandVariantGroup('a b c')).toEqual('a b c')
expect(expandVariantGroup('a:b:c')).toEqual('a:b:c')
expect(expandVariantGroup('hello a:(b c) c:(a:b d)')).toEqual('hello a:b a:c c:a:b c:d')
})
test('hoist-important', async () => {
expect(expandVariantGroup('b:c:d:(!a z)')).toEqual('!b:c:d:a b:c:d:z')
})
test('dash separator', async () => {
expect(expandVariantGroup('a-(b c) c-(a:b d)')).toEqual('a-b a-c c-a:b c-d')
})
test('tilde symbol', () => {
expect(expandVariantGroup('a-(~ b c)')).toEqual('a a-b a-c')
})
test('nested', () => {
expect(expandVariantGroup('a-(b c-(d e f))')).toEqual('a-b a-c-d a-c-e a-c-f')
})
test('spaces', () => {
expect(expandVariantGroup('a-( ~ b c )')).toEqual('a a-b a-c')
})
test('square bracket', async () => {
expect(expandVariantGroup('b:[&:not(c)]:d:(!a z)')).toEqual('!b:[&:not(c)]:d:a b:[&:not(c)]:d:z')
})
test('square bracket case2', async () => {
expect(expandVariantGroup('[&]:(a-b c-d)')).toEqual('[&]:a-b [&]:c-d')
})
test('expand with space', async () => {
const shortcut = ' a:(b:(c-d d-c)) '
expect(expandVariantGroup(shortcut)).toEqual(' a:b:c-d a:b:d-c ')
expect(expandVariantGroup(shortcut.trim()).split(/\s+/g)).toMatchInlineSnapshot(`
[
"a:b:c-d",
"a:b:d-c",
]
`)
})
test('expand @', async () => {
expect(expandVariantGroup('@a:(c-d d-c)')).toEqual('@a:c-d @a:d-c')
expect(expandVariantGroup('!@a:(c-d d-c)')).toEqual('!@a:c-d !@a:d-c')
})
})