-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.test.js
73 lines (63 loc) · 1.71 KB
/
index.test.js
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
let { equal } = require('uvu/assert')
let { test } = require('uvu')
let postcss = require('postcss')
let plugin = require('./')
function run(input, output, opts = {}) {
let result = postcss([plugin(opts)]).process(input, { from: undefined })
equal(result.css, output)
equal(result.warnings().length, 0)
}
test('adds focus selector', () => {
run('a:hover, b {}', 'a:hover, b {}a:focus-visible {}')
})
test('supports old focus', () => {
run('a:hover, b {}', 'a:hover, b {}a:focus {}', {
oldFocus: true
})
})
test('supports non-splitting', () => {
run('a:hover, b {}', 'a:hover, b, a:focus-visible {}', {
splitRules: false
})
})
test('supports split rules', () => {
run('a:hover, b {}', 'a:hover, b {}a:focus-visible {}')
})
test('supports split rules and old focus', () => {
run('a:hover, b {}', 'a:hover, b, a:focus {}', {
oldFocus: true,
splitRules: false
})
})
test('adds focus selectors', () => {
run(
'a:hover, b:hover {}',
'a:hover, b:hover {}a:focus-visible, b:focus-visible {}'
)
})
test('ignores hover selector because of focus', () => {
run(
'.foo:hover {} .foo:focus-visible {} ' +
'a:hover, b:hover {} ' +
'b:focus-visible {} ' +
'@media { b:hover {} }',
'.foo:hover {} .foo:focus-visible {} ' +
'a:hover, b:hover {} a:focus-visible {} ' +
'b:focus-visible {} ' +
'@media { b:hover {} b:focus-visible {} }'
)
run(
'.foo:hover {} .foo:focus {} ' +
'a:hover, b:hover {} ' +
'b:focus {} ' +
'@media { b:hover {} }',
'.foo:hover {} .foo:focus {} ' +
'a:hover, b:hover {} a:focus {} ' +
'b:focus {} ' +
'@media { b:hover {} b:focus {} }',
{
oldFocus: true
}
)
})
test.run()