Skip to content

Commit c72b4be

Browse files
committed
add advanced test with various combinations
1 parent ee53aed commit c72b4be

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

packages/@tailwindcss-upgrade/src/codemods/migrate-at-layer-utilities.test.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,3 +419,78 @@ it('should not migrate nested classes inside a `:not(…)`', async () => {
419419
"
420420
`)
421421
})
422+
423+
it('should migrate advanced combinations', async () => {
424+
expect(
425+
await migrate(css`
426+
@layer utilities {
427+
@media (width >= 100px) {
428+
@supports (display: none) {
429+
.foo .bar:not(.qux):has(.baz) {
430+
display: none;
431+
}
432+
}
433+
434+
.bar {
435+
color: red;
436+
}
437+
}
438+
439+
@media (width >= 200px) {
440+
.foo {
441+
&:hover {
442+
@apply bg-red-500;
443+
444+
.bar {
445+
color: red;
446+
}
447+
}
448+
}
449+
}
450+
}
451+
`),
452+
).toMatchInlineSnapshot(`
453+
"@utility foo {
454+
@media (width >= 100px) {
455+
@supports (display: none) {
456+
& .bar:not(.qux):has(.baz) {
457+
display: none;
458+
}
459+
}
460+
}
461+
@media (width >= 200px) {
462+
&:hover {
463+
@apply bg-red-500;
464+
465+
.bar {
466+
color: red;
467+
}
468+
}
469+
}
470+
}
471+
@utility bar {
472+
@media (width >= 100px) {
473+
@supports (display: none) {
474+
.foo &:not(.qux):has(.baz) {
475+
display: none;
476+
}
477+
}
478+
}
479+
@media (width >= 100px) {
480+
color: red;
481+
}
482+
}
483+
@utility baz {
484+
@media (width >= 100px) {
485+
@supports (display: none) {
486+
.foo .bar:not(.qux):has(&) {
487+
display: none;
488+
}
489+
}
490+
}
491+
}
492+
493+
494+
"
495+
`)
496+
})

0 commit comments

Comments
 (0)