forked from tailwindlabs/tailwindcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprefixSelector.test.js
More file actions
26 lines (21 loc) · 888 Bytes
/
prefixSelector.test.js
File metadata and controls
26 lines (21 loc) · 888 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
import prefix from '../src/util/prefixSelector'
test('it prefixes classes with the provided prefix', () => {
expect(prefix('tw-', '.foo')).toEqual('.tw-foo')
})
test('it handles a function as the prefix', () => {
const prefixFunc = selector => {
return selector === '.foo' ? 'tw-' : ''
}
expect(prefix(prefixFunc, '.foo')).toEqual('.tw-foo')
expect(prefix(prefixFunc, '.bar')).toEqual('.bar')
})
test('it properly prefixes selectors with non-standard characters', () => {
expect(prefix('tw-', '.hello\\:world')).toEqual('.tw-hello\\:world')
expect(prefix('tw-', '.foo\\/bar')).toEqual('.tw-foo\\/bar')
expect(prefix('tw-', '.wew\\.lad')).toEqual('.tw-wew\\.lad')
})
test('it prefixes all classes in a selector', () => {
expect(prefix('tw-', '.btn-blue .w-1\\/4 > h1.text-xl + a .bar')).toEqual(
'.tw-btn-blue .tw-w-1\\/4 > h1.tw-text-xl + a .tw-bar'
)
})