Add test coverage for purging with important string

This commit is contained in:
Adam Wathan 2020-08-20 13:25:18 -04:00
parent 52f1a2d136
commit 2903811767
2 changed files with 22 additions and 1 deletions

View file

@ -3,7 +3,7 @@
<head>
<title>My Page</title>
</head>
<body>
<body id="tailwind">
<main>
<div class="bg-red-500 md:bg-blue-300 w-1/2"></div>
</main>

View file

@ -80,6 +80,27 @@ test('purges unused classes', () => {
})
})
test('purges unused classes with important string', () => {
const OLD_NODE_ENV = process.env.NODE_ENV
process.env.NODE_ENV = 'production'
const inputPath = path.resolve(`${__dirname}/fixtures/tailwind-input.css`)
const input = fs.readFileSync(inputPath, 'utf8')
return postcss([
tailwind({
...config,
important: '#tailwind',
purge: [path.resolve(`${__dirname}/fixtures/**/*.html`)],
}),
])
.process(input, { from: inputPath })
.then(result => {
process.env.NODE_ENV = OLD_NODE_ENV
assertPurged(result)
})
})
test('does not purge components', () => {
const OLD_NODE_ENV = process.env.NODE_ENV
process.env.NODE_ENV = 'production'