@@ -4,6 +4,16 @@ import postcss from 'postcss'
4
4
import tailwind from '../src/index'
5
5
import defaultConfig from '../stubs/defaultConfig.stub.js'
6
6
7
+ function suppressConsoleLogs ( cb , type = 'warn' ) {
8
+ return ( ) => {
9
+ const spy = jest . spyOn ( global . console , type ) . mockImplementation ( jest . fn ( ) )
10
+
11
+ return new Promise ( ( resolve , reject ) => {
12
+ Promise . resolve ( cb ( ) ) . then ( resolve , reject )
13
+ } ) . finally ( ( ) => spy . mockRestore ( ) )
14
+ }
15
+ }
16
+
7
17
const config = {
8
18
...defaultConfig ,
9
19
theme : {
@@ -146,29 +156,32 @@ test('does not purge except in production', () => {
146
156
} )
147
157
} )
148
158
149
- test ( 'does not purge if the array is empty' , ( ) => {
150
- const OLD_NODE_ENV = process . env . NODE_ENV
151
- process . env . NODE_ENV = 'production'
152
- const inputPath = path . resolve ( `${ __dirname } /fixtures/tailwind-input.css` )
153
- const input = fs . readFileSync ( inputPath , 'utf8' )
154
-
155
- return postcss ( [
156
- tailwind ( {
157
- ...defaultConfig ,
158
- purge : [ ] ,
159
- } ) ,
160
- ] )
161
- . process ( input , { from : inputPath } )
162
- . then ( result => {
163
- process . env . NODE_ENV = OLD_NODE_ENV
164
- const expected = fs . readFileSync (
165
- path . resolve ( `${ __dirname } /fixtures/tailwind-output.css` ) ,
166
- 'utf8'
167
- )
168
-
169
- expect ( result . css ) . toBe ( expected )
170
- } )
171
- } )
159
+ test (
160
+ 'does not purge if the array is empty' ,
161
+ suppressConsoleLogs ( ( ) => {
162
+ const OLD_NODE_ENV = process . env . NODE_ENV
163
+ process . env . NODE_ENV = 'production'
164
+ const inputPath = path . resolve ( `${ __dirname } /fixtures/tailwind-input.css` )
165
+ const input = fs . readFileSync ( inputPath , 'utf8' )
166
+
167
+ return postcss ( [
168
+ tailwind ( {
169
+ ...defaultConfig ,
170
+ purge : [ ] ,
171
+ } ) ,
172
+ ] )
173
+ . process ( input , { from : inputPath } )
174
+ . then ( result => {
175
+ process . env . NODE_ENV = OLD_NODE_ENV
176
+ const expected = fs . readFileSync (
177
+ path . resolve ( `${ __dirname } /fixtures/tailwind-output.css` ) ,
178
+ 'utf8'
179
+ )
180
+
181
+ expect ( result . css ) . toBe ( expected )
182
+ } )
183
+ } )
184
+ )
172
185
173
186
test ( 'does not purge if explicitly disabled' , ( ) => {
174
187
const OLD_NODE_ENV = process . env . NODE_ENV
0 commit comments