@@ -56,8 +56,8 @@ describe('compiling CSS', () => {
56
56
` )
57
57
} )
58
58
59
- test ( 'that only CSS variables are allowed' , ( ) =>
60
- expect (
59
+ test ( 'that only CSS variables are allowed' , ( ) => {
60
+ return expect (
61
61
compileCss (
62
62
css `
63
63
@theme {
@@ -79,7 +79,8 @@ describe('compiling CSS', () => {
79
79
> }
80
80
}
81
81
]
82
- ` ) )
82
+ ` )
83
+ } )
83
84
84
85
test ( '`@tailwind utilities` is only processed once' , async ( ) => {
85
86
expect (
@@ -290,7 +291,7 @@ describe('@apply', () => {
290
291
} )
291
292
292
293
it ( 'should error when using @apply with a utility that does not exist' , ( ) => {
293
- expect (
294
+ return expect (
294
295
compileCss ( css `
295
296
@tailwind utilities;
296
297
@@ -304,7 +305,7 @@ describe('@apply', () => {
304
305
} )
305
306
306
307
it ( 'should error when using @apply with a variant that does not exist' , ( ) => {
307
- expect (
308
+ return expect (
308
309
compileCss ( css `
309
310
@tailwind utilities;
310
311
@@ -1184,8 +1185,8 @@ describe('Parsing themes values from CSS', () => {
1184
1185
` )
1185
1186
} )
1186
1187
1187
- test ( '`@media theme(…)` can only contain `@theme` rules' , ( ) =>
1188
- expect (
1188
+ test ( '`@media theme(…)` can only contain `@theme` rules' , ( ) => {
1189
+ return expect (
1189
1190
compileCss (
1190
1191
css `
1191
1192
@media theme(reference) {
@@ -1199,7 +1200,8 @@ describe('Parsing themes values from CSS', () => {
1199
1200
) ,
1200
1201
) . rejects . toThrowErrorMatchingInlineSnapshot (
1201
1202
`[Error: Files imported with \`@import "…" theme(…)\` must only contain \`@theme\` blocks.]` ,
1202
- ) )
1203
+ )
1204
+ } )
1203
1205
1204
1206
test ( 'theme values added as `inline` are not wrapped in `var(…)` when used as utility values' , async ( ) => {
1205
1207
expect (
@@ -1550,8 +1552,8 @@ describe('Parsing themes values from CSS', () => {
1550
1552
} )
1551
1553
1552
1554
describe ( 'plugins' , ( ) => {
1553
- test ( '@plugin need a path' , ( ) =>
1554
- expect (
1555
+ test ( '@plugin need a path' , ( ) => {
1556
+ return expect (
1555
1557
compile (
1556
1558
css `
1557
1559
@plugin ;
@@ -1565,10 +1567,11 @@ describe('plugins', () => {
1565
1567
} ) ,
1566
1568
} ,
1567
1569
) ,
1568
- ) . rejects . toThrowErrorMatchingInlineSnapshot ( `[Error: \`@plugin\` must have a path.]` ) )
1570
+ ) . rejects . toThrowErrorMatchingInlineSnapshot ( `[Error: \`@plugin\` must have a path.]` )
1571
+ } )
1569
1572
1570
- test ( '@plugin can not have an empty path' , ( ) =>
1571
- expect (
1573
+ test ( '@plugin can not have an empty path' , ( ) => {
1574
+ return expect (
1572
1575
compile (
1573
1576
css `
1574
1577
@plugin '';
@@ -1582,10 +1585,11 @@ describe('plugins', () => {
1582
1585
} ) ,
1583
1586
} ,
1584
1587
) ,
1585
- ) . rejects . toThrowErrorMatchingInlineSnapshot ( `[Error: \`@plugin\` must have a path.]` ) )
1588
+ ) . rejects . toThrowErrorMatchingInlineSnapshot ( `[Error: \`@plugin\` must have a path.]` )
1589
+ } )
1586
1590
1587
- test ( '@plugin cannot be nested.' , ( ) =>
1588
- expect (
1591
+ test ( '@plugin cannot be nested.' , ( ) => {
1592
+ return expect (
1589
1593
compile (
1590
1594
css `
1591
1595
div {
@@ -1601,7 +1605,8 @@ describe('plugins', () => {
1601
1605
} ) ,
1602
1606
} ,
1603
1607
) ,
1604
- ) . rejects . toThrowErrorMatchingInlineSnapshot ( `[Error: \`@plugin\` cannot be nested.]` ) )
1608
+ ) . rejects . toThrowErrorMatchingInlineSnapshot ( `[Error: \`@plugin\` cannot be nested.]` )
1609
+ } )
1605
1610
1606
1611
test ( '@plugin can accept options' , async ( ) => {
1607
1612
expect . hasAssertions ( )
@@ -1694,7 +1699,7 @@ describe('plugins', () => {
1694
1699
} )
1695
1700
1696
1701
test ( '@plugin options can only be simple key/value pairs' , ( ) => {
1697
- expect (
1702
+ return expect (
1698
1703
compile (
1699
1704
css `
1700
1705
@plugin "my-plugin" {
@@ -1736,7 +1741,7 @@ describe('plugins', () => {
1736
1741
} )
1737
1742
1738
1743
test ( '@plugin options can only be provided to plugins using withOptions' , ( ) => {
1739
- expect (
1744
+ return expect (
1740
1745
compile (
1741
1746
css `
1742
1747
@plugin "my-plugin" {
@@ -1762,7 +1767,7 @@ describe('plugins', () => {
1762
1767
} )
1763
1768
1764
1769
test ( '@plugin errors on array-like syntax' , ( ) => {
1765
- expect (
1770
+ return expect (
1766
1771
compile (
1767
1772
css `
1768
1773
@plugin "my-plugin" {
@@ -1779,7 +1784,7 @@ describe('plugins', () => {
1779
1784
} )
1780
1785
1781
1786
test ( '@plugin errors on object-like syntax' , ( ) => {
1782
- expect (
1787
+ return expect (
1783
1788
compile (
1784
1789
css `
1785
1790
@plugin "my-plugin" {
@@ -1794,17 +1799,15 @@ describe('plugins', () => {
1794
1799
loadModule : async ( ) => ( { module : plugin ( ( ) => { } ) , base : '/root' } ) ,
1795
1800
} ,
1796
1801
) ,
1797
- ) . rejects . toThrowErrorMatchingInlineSnapshot (
1798
- `
1802
+ ) . rejects . toThrowErrorMatchingInlineSnapshot ( `
1799
1803
[Error: Unexpected \`@plugin\` option: Value of declaration \`--color: {
1800
1804
red: 100;
1801
1805
green: 200;
1802
1806
blue: 300;
1803
1807
};\` is not supported.
1804
1808
1805
1809
Using an object as a plugin option is currently only supported in JavaScript configuration files.]
1806
- ` ,
1807
- )
1810
+ ` )
1808
1811
} )
1809
1812
1810
1813
test ( 'addVariant with string selector' , async ( ) => {
@@ -2066,36 +2069,39 @@ describe('@source', () => {
2066
2069
} )
2067
2070
2068
2071
describe ( '@variant' , ( ) => {
2069
- test ( '@variant must be top-level and cannot be nested' , ( ) =>
2070
- expect (
2072
+ test ( '@variant must be top-level and cannot be nested' , ( ) => {
2073
+ return expect (
2071
2074
compileCss ( css `
2072
2075
.foo {
2073
2076
@variant hocus (& : hover, & : focus);
2074
2077
}
2075
2078
` ) ,
2076
- ) . rejects . toThrowErrorMatchingInlineSnapshot ( `[Error: \`@variant\` cannot be nested.]` ) )
2079
+ ) . rejects . toThrowErrorMatchingInlineSnapshot ( `[Error: \`@variant\` cannot be nested.]` )
2080
+ } )
2077
2081
2078
- test ( '@variant with no body must include a selector' , ( ) =>
2079
- expect (
2082
+ test ( '@variant with no body must include a selector' , ( ) => {
2083
+ return expect (
2080
2084
compileCss ( css `
2081
2085
@variant hocus;
2082
2086
` ) ,
2083
2087
) . rejects . toThrowErrorMatchingInlineSnapshot (
2084
2088
'[Error: `@variant hocus` has no selector or body.]' ,
2085
- ) )
2089
+ )
2090
+ } )
2086
2091
2087
- test ( '@variant with selector must include a body' , ( ) =>
2088
- expect (
2092
+ test ( '@variant with selector must include a body' , ( ) => {
2093
+ return expect (
2089
2094
compileCss ( css `
2090
2095
@variant hocus {
2091
2096
}
2092
2097
` ) ,
2093
2098
) . rejects . toThrowErrorMatchingInlineSnapshot (
2094
2099
'[Error: `@variant hocus` has no selector or body.]' ,
2095
- ) )
2100
+ )
2101
+ } )
2096
2102
2097
- test ( '@variant cannot have both a selector and a body' , ( ) =>
2098
- expect (
2103
+ test ( '@variant cannot have both a selector and a body' , ( ) => {
2104
+ return expect (
2099
2105
compileCss ( css `
2100
2106
@variant hocus (& : hover , & : focus ) {
2101
2107
& : is (.potato ) {
@@ -2105,7 +2111,8 @@ describe('@variant', () => {
2105
2111
` ) ,
2106
2112
) . rejects . toThrowErrorMatchingInlineSnapshot (
2107
2113
`[Error: \`@variant hocus\` cannot have both a selector and a body.]` ,
2108
- ) )
2114
+ )
2115
+ } )
2109
2116
2110
2117
describe ( 'body-less syntax' , ( ) => {
2111
2118
test ( 'selector variant' , async ( ) => {
@@ -2573,6 +2580,43 @@ describe('@variant', () => {
2573
2580
} )
2574
2581
} )
2575
2582
2583
+ describe ( '@utility' , ( ) => {
2584
+ test ( '@utility must be top-level and cannot be nested' , ( ) => {
2585
+ return expect (
2586
+ compileCss ( css `
2587
+ .foo {
2588
+ @utility foo {
2589
+ color : red;
2590
+ }
2591
+ }
2592
+ ` ) ,
2593
+ ) . rejects . toThrowErrorMatchingInlineSnapshot ( `[Error: \`@utility\` cannot be nested.]` )
2594
+ } )
2595
+
2596
+ test ( '@utility must include a body' , ( ) => {
2597
+ return expect (
2598
+ compileCss ( css `
2599
+ @utility foo {
2600
+ }
2601
+ ` ) ,
2602
+ ) . rejects . toThrowErrorMatchingInlineSnapshot (
2603
+ `[Error: \`@utility foo\` is empty. Utilities should include at least one property.]` ,
2604
+ )
2605
+ } )
2606
+
2607
+ test ( '@utility cannot contain any special characters' , ( ) => {
2608
+ return expect (
2609
+ compileCss ( css `
2610
+ @utility 💨 {
2611
+ color : red;
2612
+ }
2613
+ ` ) ,
2614
+ ) . rejects . toThrowErrorMatchingInlineSnapshot (
2615
+ `[Error: \`@utility 💨\` defines an invalid utility name. Utilities should be alphanumeric and start with a lowercase letter.]` ,
2616
+ )
2617
+ } )
2618
+ } )
2619
+
2576
2620
test ( 'addBase' , async ( ) => {
2577
2621
let { build } = await compile (
2578
2622
css `
0 commit comments