Add sanity test for enabling important option

This commit is contained in:
Adam Wathan 2019-01-18 08:54:58 -05:00
parent df507aba24
commit 269b244b8d
3 changed files with 28403 additions and 4 deletions

File diff suppressed because it is too large Load diff

View file

@ -2,10 +2,8 @@ import fs from 'fs'
import path from 'path'
import postcss from 'postcss'
import tailwind from '../src/index'
import config from '../defaultConfig.js'
/**
* Tests
*/
it('generates the right CSS', () => {
const inputPath = path.resolve(`${__dirname}/fixtures/tailwind-input.css`)
const input = fs.readFileSync(inputPath, 'utf8')
@ -22,6 +20,22 @@ it('generates the right CSS', () => {
})
})
it('generates the right CSS when "important" is enabled', () => {
const inputPath = path.resolve(`${__dirname}/fixtures/tailwind-input.css`)
const input = fs.readFileSync(inputPath, 'utf8')
return postcss([tailwind({ ...config, options: { ...config.options, important: true }})])
.process(input, { from: inputPath })
.then(result => {
const expected = fs.readFileSync(
path.resolve(`${__dirname}/fixtures/tailwind-output-important.css`),
'utf8'
)
expect(result.css).toBe(expected)
})
})
it('does not add any CSS if no Tailwind features are used', () => {
return postcss([tailwind()])
.process('.foo { color: blue; }', { from: undefined })

View file

@ -10,7 +10,8 @@ function buildDistFile(filename) {
fs.readFile(`./${filename}.css`, (err, css) => {
if (err) throw err
return postcss([tailwind(), require('autoprefixer')])
// return postcss([tailwind(), require('autoprefixer')])
return postcss([tailwind()])
.process(css, {
from: `./${filename}.css`,
to: `./dist/${filename}.css`,