@@ -171,78 +171,81 @@ for (let transformer of ['postcss', 'lightningcss']) {
171
171
// Candidates are resolved lazily, so the first visit of index.html
172
172
// will only have candidates from this file.
173
173
await retryAssertion ( async ( ) => {
174
- let css = await fetchStyles ( port , '/index.html' )
175
- expect ( css ) . toContain ( candidate `underline` )
176
- expect ( css ) . toContain ( candidate `flex` )
177
- expect ( css ) . not . toContain ( candidate `font-bold` )
174
+ let styles = await fetchStyles ( port , '/index.html' )
175
+ expect ( styles ) . toContain ( candidate `underline` )
176
+ expect ( styles ) . toContain ( candidate `flex` )
177
+ expect ( styles ) . not . toContain ( candidate `font-bold` )
178
178
} )
179
179
180
180
// Going to about.html will extend the candidate list to include
181
181
// candidates from about.html.
182
182
await retryAssertion ( async ( ) => {
183
- let css = await fetchStyles ( port , '/about.html' )
184
- expect ( css ) . toContain ( candidate `underline` )
185
- expect ( css ) . toContain ( candidate `flex` )
186
- expect ( css ) . toContain ( candidate `font-bold` )
183
+ let styles = await fetchStyles ( port , '/about.html' )
184
+ expect ( styles ) . toContain ( candidate `underline` )
185
+ expect ( styles ) . toContain ( candidate `flex` )
186
+ expect ( styles ) . toContain ( candidate `font-bold` )
187
187
} )
188
188
189
- // Updates are additive and cause new candidates to be added.
190
- await fs . write (
191
- 'project-a/index.html' ,
192
- html `
193
- <head>
194
- <link rel="stylesheet" href="./src/index.css" />
195
- </head>
196
- <body>
197
- <div class="underline m-2">Hello, world!</div>
198
- </body>
199
- ` ,
200
- )
201
189
await retryAssertion ( async ( ) => {
202
- let css = await fetchStyles ( port )
203
- expect ( css ) . toContain ( candidate `underline` )
204
- expect ( css ) . toContain ( candidate `flex` )
205
- expect ( css ) . toContain ( candidate `font-bold` )
206
- expect ( css ) . toContain ( candidate `m-2` )
190
+ // Updates are additive and cause new candidates to be added.
191
+ await fs . write (
192
+ 'project-a/index.html' ,
193
+ html `
194
+ <head>
195
+ <link rel="stylesheet" href="./src/index.css" />
196
+ </head>
197
+ <body>
198
+ <div class="underline m-2">Hello, world!</div>
199
+ </body>
200
+ ` ,
201
+ )
202
+
203
+ let styles = await fetchStyles ( port )
204
+ expect ( styles ) . toContain ( candidate `underline` )
205
+ expect ( styles ) . toContain ( candidate `flex` )
206
+ expect ( styles ) . toContain ( candidate `font-bold` )
207
+ expect ( styles ) . toContain ( candidate `m-2` )
207
208
} )
208
209
209
- // Manually added `@source`s are watched and trigger a rebuild
210
- await fs . write (
211
- 'project-b/src/index.js' ,
212
- js `
213
- const className = "[.changed_&]:content-['project-b/src/index.js']"
214
- module.exports = { className }
215
- ` ,
216
- )
217
210
await retryAssertion ( async ( ) => {
218
- let css = await fetchStyles ( port )
219
- expect ( css ) . toContain ( candidate `underline` )
220
- expect ( css ) . toContain ( candidate `flex` )
221
- expect ( css ) . toContain ( candidate `font-bold` )
222
- expect ( css ) . toContain ( candidate `m-2` )
223
- expect ( css ) . toContain ( candidate `[.changed_&]:content-['project-b/src/index.js']` )
224
- } )
211
+ // Manually added `@source`s are watched and trigger a rebuild
212
+ await fs . write (
213
+ 'project-b/src/index.js' ,
214
+ js `
215
+ const className = "[.changed_&]:content-['project-b/src/index.js']"
216
+ module.exports = { className }
217
+ ` ,
218
+ )
225
219
226
- // After updates to the CSS file, all previous candidates should still be in
227
- // the generated CSS
228
- await fs . write (
229
- 'project-a/src/index.css' ,
230
- css `
231
- ${ await fs . read ( 'project-a/src/index.css' ) }
220
+ let styles = await fetchStyles ( port )
221
+ expect ( styles ) . toContain ( candidate `underline` )
222
+ expect ( styles ) . toContain ( candidate `flex` )
223
+ expect ( styles ) . toContain ( candidate `font-bold` )
224
+ expect ( styles ) . toContain ( candidate `m-2` )
225
+ expect ( styles ) . toContain ( candidate `[.changed_&]:content-['project-b/src/index.js']` )
226
+ } )
232
227
233
- .red {
234
- color: red;
235
- }
236
- ` ,
237
- )
238
228
await retryAssertion ( async ( ) => {
239
- let css = await fetchStyles ( port )
240
- expect ( css ) . toContain ( candidate `red` )
241
- expect ( css ) . toContain ( candidate `flex` )
242
- expect ( css ) . toContain ( candidate `m-2` )
243
- expect ( css ) . toContain ( candidate `underline` )
244
- expect ( css ) . toContain ( candidate `[.changed_&]:content-['project-b/src/index.js']` )
245
- expect ( css ) . toContain ( candidate `font-bold` )
229
+ // After updates to the CSS file, all previous candidates should still be in
230
+ // the generated CSS
231
+ await fs . write (
232
+ 'project-a/src/index.css' ,
233
+ css `
234
+ ${ await fs . read ( 'project-a/src/index.css' ) }
235
+
236
+ .red {
237
+ color: red;
238
+ }
239
+ ` ,
240
+ )
241
+
242
+ let styles = await fetchStyles ( port )
243
+ expect ( styles ) . toContain ( candidate `red` )
244
+ expect ( styles ) . toContain ( candidate `flex` )
245
+ expect ( styles ) . toContain ( candidate `m-2` )
246
+ expect ( styles ) . toContain ( candidate `underline` )
247
+ expect ( styles ) . toContain ( candidate `[.changed_&]:content-['project-b/src/index.js']` )
248
+ expect ( styles ) . toContain ( candidate `font-bold` )
246
249
} )
247
250
} ,
248
251
)
@@ -337,51 +340,53 @@ for (let transformer of ['postcss', 'lightningcss']) {
337
340
338
341
let files = await fs . glob ( 'project-a/dist/**/*.css' )
339
342
expect ( files ) . toHaveLength ( 1 )
340
- let [ , css ] = files [ 0 ]
341
- expect ( css ) . toContain ( candidate `underline` )
342
- expect ( css ) . toContain ( candidate `flex` )
343
- expect ( css ) . toContain ( candidate `m-2` )
343
+ let [ , styles ] = files [ 0 ]
344
+ expect ( styles ) . toContain ( candidate `underline` )
345
+ expect ( styles ) . toContain ( candidate `flex` )
346
+ expect ( styles ) . toContain ( candidate `m-2` )
344
347
} )
345
348
346
- // Manually added `@source`s are watched and trigger a rebuild
347
- await fs . write (
348
- 'project-b/src/index.js' ,
349
- js `
350
- const className = "[.changed_&]:content-['project-b/src/index.js']"
351
- module.exports = { className }
352
- ` ,
353
- )
354
349
await retryAssertion ( async ( ) => {
350
+ // Manually added `@source`s are watched and trigger a rebuild
351
+ await fs . write (
352
+ 'project-b/src/index.js' ,
353
+ js `
354
+ const className = "[.changed_&]:content-['project-b/src/index.js']"
355
+ module.exports = { className }
356
+ ` ,
357
+ )
358
+
355
359
let files = await fs . glob ( 'project-a/dist/**/*.css' )
356
360
expect ( files ) . toHaveLength ( 1 )
357
- let [ , css ] = files [ 0 ]
358
- expect ( css ) . toContain ( candidate `underline` )
359
- expect ( css ) . toContain ( candidate `flex` )
360
- expect ( css ) . toContain ( candidate `m-2` )
361
- expect ( css ) . toContain ( candidate `[.changed_&]:content-['project-b/src/index.js']` )
361
+ let [ , styles ] = files [ 0 ]
362
+ expect ( styles ) . toContain ( candidate `underline` )
363
+ expect ( styles ) . toContain ( candidate `flex` )
364
+ expect ( styles ) . toContain ( candidate `m-2` )
365
+ expect ( styles ) . toContain ( candidate `[.changed_&]:content-['project-b/src/index.js']` )
362
366
} )
363
367
364
- // After updates to the CSS file, all previous candidates should still be in
365
- // the generated CSS
366
- await fs . write (
367
- 'project-a/src/index.css' ,
368
- css `
369
- ${ await fs . read ( 'project-a/src/index.css' ) }
370
-
371
- .red {
372
- color: red;
373
- }
374
- ` ,
375
- )
376
368
await retryAssertion ( async ( ) => {
369
+ // After updates to the CSS file, all previous candidates should still be in
370
+ // the generated CSS
371
+ await fs . write (
372
+ 'project-a/src/index.css' ,
373
+ css `
374
+ ${ await fs . read ( 'project-a/src/index.css' ) }
375
+
376
+ .red {
377
+ color: red;
378
+ }
379
+ ` ,
380
+ )
381
+
377
382
let files = await fs . glob ( 'project-a/dist/**/*.css' )
378
383
expect ( files ) . toHaveLength ( 1 )
379
- let [ , css ] = files [ 0 ]
380
- expect ( css ) . toContain ( candidate `underline` )
381
- expect ( css ) . toContain ( candidate `flex` )
382
- expect ( css ) . toContain ( candidate `m-2` )
383
- expect ( css ) . toContain ( candidate `[.changed_&]:content-['project-b/src/index.js']` )
384
- expect ( css ) . toContain ( candidate `red` )
384
+ let [ , styles ] = files [ 0 ]
385
+ expect ( styles ) . toContain ( candidate `underline` )
386
+ expect ( styles ) . toContain ( candidate `flex` )
387
+ expect ( styles ) . toContain ( candidate `m-2` )
388
+ expect ( styles ) . toContain ( candidate `[.changed_&]:content-['project-b/src/index.js']` )
389
+ expect ( styles ) . toContain ( candidate `red` )
385
390
} )
386
391
} ,
387
392
)
@@ -439,25 +444,26 @@ test(
439
444
// Candidates are resolved lazily, so the first visit of index.html
440
445
// will only have candidates from this file.
441
446
await retryAssertion ( async ( ) => {
442
- let css = await fetchStyles ( port , '/index.html' )
443
- expect ( css ) . toContain ( candidate `underline` )
444
- expect ( css ) . not . toContain ( candidate `font-bold` )
447
+ let styles = await fetchStyles ( port , '/index.html' )
448
+ expect ( styles ) . toContain ( candidate `underline` )
449
+ expect ( styles ) . not . toContain ( candidate `font-bold` )
445
450
} )
446
451
447
452
// Going to about.html will extend the candidate list to include
448
453
// candidates from about.html.
449
454
await retryAssertion ( async ( ) => {
450
- let css = await fetchStyles ( port , '/about.html' )
451
- expect ( css ) . toContain ( candidate `underline` )
452
- expect ( css ) . toContain ( candidate `font-bold` )
455
+ let styles = await fetchStyles ( port , '/about.html' )
456
+ expect ( styles ) . toContain ( candidate `underline` )
457
+ expect ( styles ) . toContain ( candidate `font-bold` )
453
458
} )
454
459
455
- // We change the CSS file so it is no longer a valid Tailwind root.
456
- await fs . write ( 'src/index.css' , css `@import 'tailwindcss';` )
457
460
await retryAssertion ( async ( ) => {
458
- let css = await fetchStyles ( port )
459
- expect ( css ) . toContain ( candidate `underline` )
460
- expect ( css ) . toContain ( candidate `font-bold` )
461
+ // We change the CSS file so it is no longer a valid Tailwind root.
462
+ await fs . write ( 'src/index.css' , css `@import 'tailwindcss';` )
463
+
464
+ let styles = await fetchStyles ( port )
465
+ expect ( styles ) . toContain ( candidate `underline` )
466
+ expect ( styles ) . toContain ( candidate `font-bold` )
461
467
} )
462
468
} ,
463
469
)
0 commit comments