-
Notifications
You must be signed in to change notification settings - Fork 4k
/
prefix.fn.test.js
34 lines (28 loc) · 858 Bytes
/
prefix.fn.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
const postcss = require('postcss')
const tailwind = require('../index.js')
const fs = require('fs')
const path = require('path')
function run(input, config = {}) {
return postcss(tailwind(config)).process(input, { from: path.resolve(__filename) })
}
test('prefix fn', () => {
let config = {
prefix(selector) {
if (['.align-bottom', '.ml'].some((prefix) => selector.startsWith(prefix))) {
return 'tw-'
}
return ''
},
purge: [path.resolve(__dirname, './prefix.fn.test.html')],
corePlugins: { preflight: false },
theme: {},
}
let css = `
@tailwind utilities;
`
return run(css, config).then((result) => {
let expectedPath = path.resolve(__dirname, './prefix.fn.test.css')
let expected = fs.readFileSync(expectedPath, 'utf8')
expect(result.css).toMatchFormattedCss(expected)
})
})