54 lines
1.1 KiB
JavaScript
54 lines
1.1 KiB
JavaScript
const _ = require('lodash')
|
|
const cssMatcher = require('jest-matcher-css')
|
|
const defaultConfig = require('tailwindcss/defaultConfig')
|
|
const plugin = require('./index.js')
|
|
const postcss = require('postcss')
|
|
const tailwindcss = require('tailwindcss')
|
|
|
|
const generatePluginCss = (options = {}) => {
|
|
return postcss(
|
|
tailwindcss({
|
|
corePlugins: false,
|
|
plugins: [plugin(options)]
|
|
})
|
|
)
|
|
.process('@tailwind utilities;', {
|
|
from: undefined
|
|
})
|
|
.then(result => {
|
|
return result.css
|
|
})
|
|
}
|
|
|
|
expect.extend({
|
|
toMatchCss: cssMatcher
|
|
})
|
|
|
|
test('it generates the correct classes with no variants', () => {
|
|
return generatePluginCss().then(css => {
|
|
expect(css).toMatchCss(`
|
|
.test {
|
|
display: block
|
|
}
|
|
`)
|
|
})
|
|
})
|
|
|
|
test('it generates the correct classes with variants', () => {
|
|
return generatePluginCss({ variants: ['hover', 'focus'] }).then(css => {
|
|
expect(css).toMatchCss(`
|
|
.test {
|
|
display: block
|
|
}
|
|
|
|
.hover\\:test:hover {
|
|
display: block
|
|
}
|
|
|
|
.focus\\:test:focus {
|
|
display: block
|
|
}
|
|
`)
|
|
})
|
|
})
|