From 2903811767fa03f559e644b5732f0ec3af32f3fd Mon Sep 17 00:00:00 2001 From: Adam Wathan Date: Thu, 20 Aug 2020 13:25:18 -0400 Subject: [PATCH] Add test coverage for purging with important string --- __tests__/fixtures/purge-example.html | 2 +- __tests__/purgeUnusedStyles.test.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/__tests__/fixtures/purge-example.html b/__tests__/fixtures/purge-example.html index 78132ef46..50ffdc3e1 100644 --- a/__tests__/fixtures/purge-example.html +++ b/__tests__/fixtures/purge-example.html @@ -3,7 +3,7 @@ My Page - +
diff --git a/__tests__/purgeUnusedStyles.test.js b/__tests__/purgeUnusedStyles.test.js index 118f21725..fa32b6ed4 100644 --- a/__tests__/purgeUnusedStyles.test.js +++ b/__tests__/purgeUnusedStyles.test.js @@ -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'