forked from tailwindlabs/tailwindcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintellisense.test.ts
More file actions
83 lines (67 loc) · 2.2 KB
/
intellisense.test.ts
File metadata and controls
83 lines (67 loc) · 2.2 KB
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
import { expect, test } from 'vitest'
import { buildDesignSystem } from './design-system'
import { Theme } from './theme'
function loadDesignSystem() {
return buildDesignSystem(
new Theme(
new Map([
['--spacing-0_5', '0.125rem'],
['--spacing-1', '0.25rem'],
['--spacing-3', '0.75rem'],
['--spacing-4', '1rem'],
['--width-4', '1rem'],
['--colors-red-500', 'red'],
['--colors-blue-500', 'blue'],
['--breakpoint-sm', '640px'],
['--font-size-xs', '0.75rem'],
['--font-size-xs--line-height', '1rem'],
]),
),
)
}
test('getClassList', () => {
let design = loadDesignSystem()
let classList = design.getClassList()
let classNames = classList.map(([name]) => name)
expect(classNames).toMatchSnapshot()
})
test('Theme values with underscores are converted back to deciaml points', () => {
let design = loadDesignSystem()
let classes = design.getClassList()
expect(classes).toContainEqual(['inset-0.5', { modifiers: [] }])
})
test('getVariants', () => {
let design = loadDesignSystem()
let variants = design.getVariants()
expect(variants).toMatchSnapshot()
})
test('getVariants compound', () => {
let design = loadDesignSystem()
let variants = design.getVariants()
let group = variants.find((v) => v.name === 'group')!
let list = [
// A selector-based variant
group.selectors({ value: 'hover' }),
// A selector-based variant with a modifier
group.selectors({ value: 'hover', modifier: 'sidebar' }),
// A nested, compound, selector-based variant
group.selectors({ value: 'group-hover' }),
// This variant produced an at rule
group.selectors({ value: 'sm' }),
// This variant does not exist
group.selectors({ value: 'md' }),
]
expect(list).toEqual([
['&:is(:where(.group):hover *)'],
['&:is(:where(.group\\/sidebar):hover *)'],
['&:is(:where(.group):is(:where(.group):hover *) *)'],
[],
[],
])
})
test('The variant `has-force` does not crash', () => {
let design = loadDesignSystem()
let variants = design.getVariants()
let has = variants.find((v) => v.name === 'has')!
expect(has.selectors({ value: 'force' })).toMatchInlineSnapshot(`[]`)
})