Skip to content

Commit 2903811

Browse files
committed
Add test coverage for purging with important string
1 parent 52f1a2d commit 2903811

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

__tests__/fixtures/purge-example.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<title>My Page</title>
55
</head>
6-
<body>
6+
<body id="tailwind">
77
<main>
88
<div class="bg-red-500 md:bg-blue-300 w-1/2"></div>
99
</main>

__tests__/purgeUnusedStyles.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,27 @@ test('purges unused classes', () => {
8080
})
8181
})
8282

83+
test('purges unused classes with important string', () => {
84+
const OLD_NODE_ENV = process.env.NODE_ENV
85+
process.env.NODE_ENV = 'production'
86+
const inputPath = path.resolve(`${__dirname}/fixtures/tailwind-input.css`)
87+
const input = fs.readFileSync(inputPath, 'utf8')
88+
89+
return postcss([
90+
tailwind({
91+
...config,
92+
important: '#tailwind',
93+
purge: [path.resolve(`${__dirname}/fixtures/**/*.html`)],
94+
}),
95+
])
96+
.process(input, { from: inputPath })
97+
.then(result => {
98+
process.env.NODE_ENV = OLD_NODE_ENV
99+
100+
assertPurged(result)
101+
})
102+
})
103+
83104
test('does not purge components', () => {
84105
const OLD_NODE_ENV = process.env.NODE_ENV
85106
process.env.NODE_ENV = 'production'

0 commit comments

Comments
 (0)