Add test for classes with variants

This commit is contained in:
Oliver Davies 2019-04-11 20:59:01 +01:00
parent 8e4de76a01
commit 73485e6d3d

24
test.js
View file

@ -11,11 +11,11 @@ const disableCorePlugins = () => {
})
}
const generatePluginCss = () => {
const generatePluginCss = (options = {}) => {
return postcss(
tailwindcss({
corePlugins: disableCorePlugins(),
plugins: [plugin()]
plugins: [plugin(options)]
})
)
.process('@tailwind utilities;', {
@ -30,7 +30,7 @@ expect.extend({
toMatchCss: cssMatcher
})
test('it generates classes', () => {
test('it generates the correct classes with no variants', () => {
return generatePluginCss().then(css => {
expect(css).toMatchCss(`
.test {
@ -39,3 +39,21 @@ test('it generates classes', () => {
`)
})
})
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;
}
`)
})
})