forked from tailwindlabs/tailwindcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprefixTree.test.js
More file actions
42 lines (34 loc) · 969 Bytes
/
prefixTree.test.js
File metadata and controls
42 lines (34 loc) · 969 Bytes
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
import postcss from 'postcss'
import prefixTree from '../src/util/prefixTree'
test('it prefixes classes with the provided prefix', () => {
const input = postcss.parse(`
.foo { color: red; }
.apple, .pear { color: green; }
`)
const expected = `
.tw-foo { color: red; }
.tw-apple, .tw-pear { color: green; }
`
const result = prefixTree(input, 'tw-').toResult()
expect(result.css).toEqual(expected)
expect(result.warnings().length).toBe(0)
})
test('it handles a function as the prefix', () => {
const input = postcss.parse(`
.foo { color: red; }
.apple, .pear { color: green; }
`)
const expected = `
.tw-foo { color: red; }
.apple, .pear { color: green; }
`
const prefixFunc = selector => {
if (selector === '.foo') {
return 'tw-'
}
return ''
}
const result = prefixTree(input, prefixFunc).toResult()
expect(result.css).toEqual(expected)
expect(result.warnings().length).toBe(0)
})