Skip to content

Commit cbcb50f

Browse files
committed
fix tests for AOT mode
1 parent bf248cb commit cbcb50f

File tree

1 file changed

+56
-11
lines changed

1 file changed

+56
-11
lines changed

tests/plugins/divide.test.js

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,42 @@
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
219

320
it('should add the divide styles for divide-y and a default border color', () => {
421
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+
},
626
corePlugins: { preflight: false },
727
}
828

929
return run('@tailwind base; @tailwind utilities;', config).then((result) => {
10-
expect(result.css).toMatchCss(css`
30+
expect(result.css).toIncludeCss(css`
1131
*,
1232
::before,
1333
::after {
1434
--tw-border-opacity: 1;
1535
border-color: rgba(229, 231, 235, var(--tw-border-opacity));
1636
}
37+
`)
1738

39+
expect(result.css).toIncludeCss(css`
1840
.divide-y > :not([hidden]) ~ :not([hidden]) {
1941
--tw-divide-y-reverse: 0;
2042
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', () =>
2648

2749
it('should add the divide styles for divide-x and a default border color', () => {
2850
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+
},
3055
corePlugins: { preflight: false },
3156
}
3257

3358
return run('@tailwind base; @tailwind utilities;', config).then((result) => {
34-
expect(result.css).toMatchCss(css`
59+
expect(result.css).toIncludeCss(css`
3560
*,
3661
::before,
3762
::after {
3863
--tw-border-opacity: 1;
3964
border-color: rgba(229, 231, 235, var(--tw-border-opacity));
4065
}
66+
`)
4167

68+
expect(result.css).toIncludeCss(css`
4269
.divide-x > :not([hidden]) ~ :not([hidden]) {
4370
--tw-divide-x-reverse: 0;
4471
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', () =>
5077

5178
it('should add the divide styles for divide-y-reverse and a default border color', () => {
5279
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+
},
5484
corePlugins: { preflight: false },
5585
}
5686

5787
return run('@tailwind base; @tailwind utilities;', config).then((result) => {
58-
expect(result.css).toMatchCss(css`
88+
expect(result.css).toIncludeCss(css`
5989
*,
6090
::before,
6191
::after {
6292
--tw-border-opacity: 1;
6393
border-color: rgba(229, 231, 235, var(--tw-border-opacity));
6494
}
95+
`)
6596

97+
expect(result.css).toIncludeCss(css`
6698
.divide-y-reverse > :not([hidden]) ~ :not([hidden]) {
6799
--tw-divide-y-reverse: 1;
68100
}
@@ -72,19 +104,24 @@ it('should add the divide styles for divide-y-reverse and a default border color
72104

73105
it('should add the divide styles for divide-x-reverse and a default border color', () => {
74106
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+
},
76111
corePlugins: { preflight: false },
77112
}
78113

79114
return run('@tailwind base; @tailwind utilities;', config).then((result) => {
80-
expect(result.css).toMatchCss(css`
115+
expect(result.css).toIncludeCss(css`
81116
*,
82117
::before,
83118
::after {
84119
--tw-border-opacity: 1;
85120
border-color: rgba(229, 231, 235, var(--tw-border-opacity));
86121
}
122+
`)
87123

124+
expect(result.css).toIncludeCss(css`
88125
.divide-x-reverse > :not([hidden]) ~ :not([hidden]) {
89126
--tw-divide-x-reverse: 1;
90127
}
@@ -94,25 +131,33 @@ it('should add the divide styles for divide-x-reverse and a default border color
94131

95132
it('should only inject the base styles once if we use divide and border at the same time', () => {
96133
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+
98139
corePlugins: { preflight: false },
99140
}
100141

101142
return run('@tailwind base; @tailwind utilities;', config).then((result) => {
102-
expect(result.css).toMatchCss(css`
143+
expect(result.css).toIncludeCss(css`
103144
*,
104145
::before,
105146
::after {
106147
--tw-border-opacity: 1;
107148
border-color: rgba(229, 231, 235, var(--tw-border-opacity));
108149
}
150+
`)
109151

152+
expect(result.css).toIncludeCss(css`
110153
.divide-y > :not([hidden]) ~ :not([hidden]) {
111154
--tw-divide-y-reverse: 0;
112155
border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
113156
border-bottom-width: calc(1px * var(--tw-divide-y-reverse));
114157
}
158+
`)
115159

160+
expect(result.css).toIncludeCss(css`
116161
.border-r {
117162
border-right-width: 1px;
118163
}

0 commit comments

Comments
 (0)