From 73485e6d3d5906357a996956a7d873bdcf0d9a0b Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 11 Apr 2019 20:59:01 +0100 Subject: [PATCH] Add test for classes with variants --- test.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/test.js b/test.js index fb41ce2..6251fc1 100644 --- a/test.js +++ b/test.js @@ -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; + } + `) + }) +})