1
1
import postcss from 'postcss'
2
2
import fs from 'fs'
3
3
import path from 'path'
4
- import tailwind from '../../src/jit/index.js'
5
4
6
- function run ( input , config = { } ) {
5
+ beforeEach ( ( ) => {
6
+ jest . resetModules ( )
7
+ } )
8
+
9
+ function run ( tailwind , input , config = { } ) {
7
10
return postcss ( tailwind ( config ) ) . process ( input , {
8
11
from : path . resolve ( __filename ) ,
9
12
} )
10
13
}
11
14
12
15
test ( 'raw content' , ( ) => {
16
+ let tailwind = require ( '../../src/jit/index.js' ) . default
17
+
13
18
let config = {
14
19
mode : 'jit' ,
15
20
purge : [ { raw : fs . readFileSync ( path . resolve ( __dirname , './raw-content.test.html' ) , 'utf8' ) } ] ,
@@ -24,10 +29,57 @@ test('raw content', () => {
24
29
@tailwind utilities;
25
30
`
26
31
27
- return run ( css , config ) . then ( ( result ) => {
32
+ return run ( tailwind , css , config ) . then ( ( result ) => {
28
33
let expectedPath = path . resolve ( __dirname , './raw-content.test.css' )
29
34
let expected = fs . readFileSync ( expectedPath , 'utf8' )
30
35
31
36
expect ( result . css ) . toMatchFormattedCss ( expected )
32
37
} )
33
38
} )
39
+
40
+ test ( 'raw content with extension' , ( ) => {
41
+ let tailwind = require ( '../../src/jit/index.js' ) . default
42
+
43
+ let config = {
44
+ mode : 'jit' ,
45
+ purge : {
46
+ content : [
47
+ {
48
+ raw : fs . readFileSync ( path . resolve ( __dirname , './raw-content.test.html' ) , 'utf8' ) ,
49
+ extension : 'html' ,
50
+ } ,
51
+ ] ,
52
+ options : {
53
+ extractors : [
54
+ {
55
+ extractor : ( ) => [ ] ,
56
+ extensions : [ 'html' ] ,
57
+ } ,
58
+ ] ,
59
+ } ,
60
+ } ,
61
+ corePlugins : { preflight : false } ,
62
+ theme : { } ,
63
+ plugins : [ ] ,
64
+ }
65
+
66
+ let css = `
67
+ @tailwind base;
68
+ @tailwind components;
69
+ @tailwind utilities;
70
+ `
71
+
72
+ return run ( tailwind , css , config ) . then ( ( result ) => {
73
+ expect ( result . css ) . toMatchFormattedCss ( `
74
+ * {
75
+ --tw-shadow: 0 0 #0000;
76
+ --tw-ring-inset: var(--tw-empty, /*!*/ /*!*/);
77
+ --tw-ring-offset-width: 0px;
78
+ --tw-ring-offset-color: #fff;
79
+ --tw-ring-color: rgba(59, 130, 246, 0.5);
80
+ --tw-ring-offset-shadow: 0 0 #0000;
81
+ --tw-ring-shadow: 0 0 #0000;
82
+ }
83
+ ` )
84
+ } )
85
+ } )
0 commit comments