Skip to content

Commit a10d21f

Browse files
Add missing test (#23)
* Add missing test Test result check is missing a class which makes the test give a false negative (false pass). * Update test * Tweak matcher * Update to latest insiders version --------- Co-authored-by: Jordan Pittman <jordan@cryptica.me>
1 parent c287ac7 commit a10d21f

File tree

3 files changed

+45
-38
lines changed

3 files changed

+45
-38
lines changed

jest/custom-matchers.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ expect.extend({
107107
printWidth: 100,
108108
})
109109
}
110+
111+
function stripped(str) {
112+
return str.replace(/\/\* ! tailwindcss .* \*\//, '').replace(/\s/g, '').replace(/;/g, '')
113+
}
114+
110115
const options = {
111116
comment: 'stripped(received) === stripped(argument)',
112117
isNot: this.isNot,
@@ -116,7 +121,7 @@ expect.extend({
116121
let formattedReceived = format(received)
117122
let formattedArgument = format(argument)
118123

119-
const pass = formattedReceived === formattedArgument
124+
const pass = stripped(formattedReceived) === stripped(formattedArgument)
120125

121126
const message = pass
122127
? () => {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"jest": "^29.1.2",
5050
"postcss": "^8.4.17",
5151
"prettier": "^2.7.1",
52-
"tailwindcss": "0.0.0-insiders.3011f46",
52+
"tailwindcss": "0.0.0-insiders.7385373",
5353
"typescript": "^4.8.4"
5454
}
5555
}

tests/index.test.ts

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ it('container queries', () => {
77
{
88
raw: html`
99
<div
10-
class="@container @container-normal @container/sidebar @container-normal/sidebar @container-[size]/sidebar"
10+
class="@container @container-normal @container/sidebar @container-normal/sidebar @container-[size] @container-[size]/sidebar"
1111
>
1212
<div class="@md:underline"></div>
1313
<div class="@md/container1:underline"></div>
@@ -54,111 +54,113 @@ it('container queries', () => {
5454
container-type: inline-size;
5555
}
5656
57+
.\@container-\[size\] {
58+
container-type: size;
59+
}
60+
61+
.\@container-\[size\]\/sidebar {
62+
container: sidebar / size;
63+
}
64+
5765
.\@container-normal {
5866
container-type: normal;
5967
}
6068
61-
.\@container\/sidebar {
62-
container-type: inline-size;
63-
container-name: sidebar;
69+
.\@container-normal\/sidebar {
70+
container: sidebar;
6471
}
6572
66-
.\@container-normal\/sidebar {
67-
container-type: normal;
68-
container-name: sidebar;
73+
.\@container\/sidebar {
74+
container: sidebar / inline-size;
6975
}
7076
71-
@container (min-width: 123px) {
77+
@container (width >= 123px) {
7278
.\@\[123px\]\:underline {
7379
text-decoration-line: underline;
7480
}
7581
}
7682
77-
@container (min-width: 200rem) {
83+
@container (width >= 200rem) {
7884
.\@\[200rem\]\:underline {
7985
text-decoration-line: underline;
8086
}
8187
}
8288
83-
@container (min-width: 312px) {
89+
@container (width >= 312px) {
8490
.\@\[312px\]\:underline {
8591
text-decoration-line: underline;
8692
}
8793
}
8894
89-
@container container1 (min-width: 320px) {
95+
@container container1 (width >= 320px) {
9096
.\@sm\/container1\:underline {
9197
text-decoration-line: underline;
9298
}
9399
}
94100
95-
@container container2 (min-width: 320px) {
101+
@container container2 (width >= 320px) {
96102
.\@sm\/container2\:underline {
97103
text-decoration-line: underline;
98104
}
99105
}
100106
101-
@container container10 (min-width: 320px) {
107+
@container container10 (width >= 320px) {
102108
.\@sm\/container10\:underline {
103109
text-decoration-line: underline;
104110
}
105111
}
106112
107-
@container (min-width: 320px) {
113+
@container (width >= 320px) {
108114
.\@sm\:underline {
109115
text-decoration-line: underline;
110116
}
111117
}
112118
113-
@container container1 (min-width: 768px) {
119+
@container container1 (width >= 768px) {
114120
.\@md\/container1\:underline {
115121
text-decoration-line: underline;
116122
}
117123
}
118124
119-
@container container2 (min-width: 768px) {
125+
@container container2 (width >= 768px) {
120126
.\@md\/container2\:underline {
121127
text-decoration-line: underline;
122128
}
123129
}
124130
125-
@container container10 (min-width: 768px) {
131+
@container container10 (width >= 768px) {
126132
.\@md\/container10\:underline {
127133
text-decoration-line: underline;
128134
}
129135
}
130136
131-
@container (min-width: 768px) {
137+
@container (width >= 768px) {
132138
.\@md\:underline {
133139
text-decoration-line: underline;
134140
}
135141
}
136142
137-
@container container1 (min-width: 1024px) {
138-
.\@lg\/container1\:underline {
139-
text-decoration-line: underline;
140-
}
143+
@container container1 (width >= 1024px) {
144+
.\@lg\/container1\:underline,
141145
.\@\[1024px\]\/container1\:underline {
142146
text-decoration-line: underline;
143147
}
144148
}
145149
146-
@container container2 (min-width: 1024px) {
150+
@container container2 (width >= 1024px) {
147151
.\@lg\/container2\:underline {
148152
text-decoration-line: underline;
149153
}
150154
}
151155
152-
@container container10 (min-width: 1024px) {
156+
@container container10 (width >= 1024px) {
153157
.\@lg\/container10\:underline {
154158
text-decoration-line: underline;
155159
}
156160
}
157161
158-
@container (min-width: 1024px) {
159-
.\@lg\:underline {
160-
text-decoration-line: underline;
161-
}
162+
@container (width >= 1024px) {
163+
.\@lg\:underline,
162164
.\@\[1024px\]\:underline {
163165
text-decoration-line: underline;
164166
}
@@ -195,49 +197,49 @@ it('should be possible to use default container queries', () => {
195197

196198
return run(input, config).then((result) => {
197199
expect(result.css).toMatchFormattedCss(css`
198-
@container (min-width: 20rem) {
200+
@container (width >= 20rem) {
199201
.\@xs\:underline {
200202
text-decoration-line: underline;
201203
}
202204
}
203205
204-
@container (min-width: 24rem) {
206+
@container (width >= 24rem) {
205207
.\@sm\:underline {
206208
text-decoration-line: underline;
207209
}
208210
}
209211
210-
@container (min-width: 28rem) {
212+
@container (width >= 28rem) {
211213
.\@md\:underline {
212214
text-decoration-line: underline;
213215
}
214216
}
215217
216-
@container (min-width: 32rem) {
218+
@container (width >= 32rem) {
217219
.\@lg\:underline {
218220
text-decoration-line: underline;
219221
}
220222
}
221223
222-
@container (min-width: 48rem) {
224+
@container (width >= 48rem) {
223225
.\@3xl\:underline {
224226
text-decoration-line: underline;
225227
}
226228
}
227229
228-
@container (min-width: 64rem) {
230+
@container (width >= 64rem) {
229231
.\@5xl\:underline {
230232
text-decoration-line: underline;
231233
}
232234
}
233235
234-
@container (min-width: 72rem) {
236+
@container (width >= 72rem) {
235237
.\@6xl\:underline {
236238
text-decoration-line: underline;
237239
}
238240
}
239241
240-
@container (min-width: 80rem) {
242+
@container (width >= 80rem) {
241243
.\@7xl\:underline {
242244
text-decoration-line: underline;
243245
}

0 commit comments

Comments
 (0)