1
- import { run , html , css } from '../util/run'
1
+ import path from 'path'
2
+ import postcss from 'postcss'
3
+ import tailwind from '../../src'
4
+
5
+ function run ( input , config , plugin = tailwind ) {
6
+ let { currentTestName } = expect . getState ( )
7
+
8
+ return postcss ( plugin ( config ) ) . process ( input , {
9
+ from : `${ path . resolve ( __filename ) } ?test=${ currentTestName } ` ,
10
+ } )
11
+ }
12
+
13
+ function syntax ( templates ) {
14
+ return templates . join ( '' )
15
+ }
16
+
17
+ let css = syntax
18
+ let html = syntax
2
19
3
20
it ( 'should add the divide styles for divide-y and a default border color' , ( ) => {
4
21
let config = {
5
- content : [ { raw : html `<div class= "divide-y" > </ div> ` } ] ,
22
+ purge : {
23
+ enabled : true ,
24
+ content : [ { raw : html `<div class= "divide-y" > </ div> ` } ] ,
25
+ } ,
6
26
corePlugins : { preflight : false } ,
7
27
}
8
28
9
29
return run ( '@tailwind base; @tailwind utilities;' , config ) . then ( ( result ) => {
10
- expect ( result . css ) . toMatchCss ( css `
30
+ expect ( result . css ) . toIncludeCss ( css `
11
31
* ,
12
32
::before ,
13
33
::after {
14
34
--tw-border-opacity : 1 ;
15
35
border-color : rgba (229 , 231 , 235 , var (--tw-border-opacity ));
16
36
}
37
+ ` )
17
38
39
+ expect ( result . css ) . toIncludeCss ( css `
18
40
.divide-y > : not ([hidden ]) ~ : not ([hidden ]) {
19
41
--tw-divide-y-reverse : 0 ;
20
42
border-top-width : calc (1px * calc (1 - var (--tw-divide-y-reverse )));
@@ -26,19 +48,24 @@ it('should add the divide styles for divide-y and a default border color', () =>
26
48
27
49
it ( 'should add the divide styles for divide-x and a default border color' , ( ) => {
28
50
let config = {
29
- content : [ { raw : html `<div class= "divide-x" > </ div> ` } ] ,
51
+ purge : {
52
+ enabled : true ,
53
+ content : [ { raw : html `<div class= "divide-x" > </ div> ` } ] ,
54
+ } ,
30
55
corePlugins : { preflight : false } ,
31
56
}
32
57
33
58
return run ( '@tailwind base; @tailwind utilities;' , config ) . then ( ( result ) => {
34
- expect ( result . css ) . toMatchCss ( css `
59
+ expect ( result . css ) . toIncludeCss ( css `
35
60
* ,
36
61
::before ,
37
62
::after {
38
63
--tw-border-opacity : 1 ;
39
64
border-color : rgba (229 , 231 , 235 , var (--tw-border-opacity ));
40
65
}
66
+ ` )
41
67
68
+ expect ( result . css ) . toIncludeCss ( css `
42
69
.divide-x > : not ([hidden ]) ~ : not ([hidden ]) {
43
70
--tw-divide-x-reverse : 0 ;
44
71
border-right-width : calc (1px * var (--tw-divide-x-reverse ));
@@ -50,19 +77,24 @@ it('should add the divide styles for divide-x and a default border color', () =>
50
77
51
78
it ( 'should add the divide styles for divide-y-reverse and a default border color' , ( ) => {
52
79
let config = {
53
- content : [ { raw : html `<div class= "divide-y-reverse" > </ div> ` } ] ,
80
+ purge : {
81
+ enabled : true ,
82
+ content : [ { raw : html `<div class= "divide-y-reverse" > </ div> ` } ] ,
83
+ } ,
54
84
corePlugins : { preflight : false } ,
55
85
}
56
86
57
87
return run ( '@tailwind base; @tailwind utilities;' , config ) . then ( ( result ) => {
58
- expect ( result . css ) . toMatchCss ( css `
88
+ expect ( result . css ) . toIncludeCss ( css `
59
89
* ,
60
90
::before ,
61
91
::after {
62
92
--tw-border-opacity : 1 ;
63
93
border-color : rgba (229 , 231 , 235 , var (--tw-border-opacity ));
64
94
}
95
+ ` )
65
96
97
+ expect ( result . css ) . toIncludeCss ( css `
66
98
.divide-y-reverse > : not ([hidden ]) ~ : not ([hidden ]) {
67
99
--tw-divide-y-reverse : 1 ;
68
100
}
@@ -72,19 +104,24 @@ it('should add the divide styles for divide-y-reverse and a default border color
72
104
73
105
it ( 'should add the divide styles for divide-x-reverse and a default border color' , ( ) => {
74
106
let config = {
75
- content : [ { raw : html `<div class= "divide-x-reverse" > </ div> ` } ] ,
107
+ purge : {
108
+ enabled : true ,
109
+ content : [ { raw : html `<div class= "divide-x-reverse" > </ div> ` } ] ,
110
+ } ,
76
111
corePlugins : { preflight : false } ,
77
112
}
78
113
79
114
return run ( '@tailwind base; @tailwind utilities;' , config ) . then ( ( result ) => {
80
- expect ( result . css ) . toMatchCss ( css `
115
+ expect ( result . css ) . toIncludeCss ( css `
81
116
* ,
82
117
::before ,
83
118
::after {
84
119
--tw-border-opacity : 1 ;
85
120
border-color : rgba (229 , 231 , 235 , var (--tw-border-opacity ));
86
121
}
122
+ ` )
87
123
124
+ expect ( result . css ) . toIncludeCss ( css `
88
125
.divide-x-reverse > : not ([hidden ]) ~ : not ([hidden ]) {
89
126
--tw-divide-x-reverse : 1 ;
90
127
}
@@ -94,25 +131,33 @@ it('should add the divide styles for divide-x-reverse and a default border color
94
131
95
132
it ( 'should only inject the base styles once if we use divide and border at the same time' , ( ) => {
96
133
let config = {
97
- content : [ { raw : html `<div class= "divide-y border-r" > </ div> ` } ] ,
134
+ purge : {
135
+ enabled : true ,
136
+ content : [ { raw : html `<div class= "divide-y border-r" > </ div> ` } ] ,
137
+ } ,
138
+
98
139
corePlugins : { preflight : false } ,
99
140
}
100
141
101
142
return run ( '@tailwind base; @tailwind utilities;' , config ) . then ( ( result ) => {
102
- expect ( result . css ) . toMatchCss ( css `
143
+ expect ( result . css ) . toIncludeCss ( css `
103
144
* ,
104
145
::before ,
105
146
::after {
106
147
--tw-border-opacity : 1 ;
107
148
border-color : rgba (229 , 231 , 235 , var (--tw-border-opacity ));
108
149
}
150
+ ` )
109
151
152
+ expect ( result . css ) . toIncludeCss ( css `
110
153
.divide-y > : not ([hidden ]) ~ : not ([hidden ]) {
111
154
--tw-divide-y-reverse : 0 ;
112
155
border-top-width : calc (1px * calc (1 - var (--tw-divide-y-reverse )));
113
156
border-bottom-width : calc (1px * var (--tw-divide-y-reverse ));
114
157
}
158
+ ` )
115
159
160
+ expect ( result . css ) . toIncludeCss ( css `
116
161
.border-r {
117
162
border-right-width : 1px ;
118
163
}
0 commit comments