1
1
import { expect , test } from 'vitest'
2
- import { compile } from '.. '
3
- import plugin from '.. /plugin'
2
+ import { compile } from '.'
3
+ import plugin from './plugin'
4
4
5
5
const css = String . raw
6
6
@@ -198,15 +198,30 @@ test('a prefix can be configured via @import theme(…)', async () => {
198
198
async loadStylesheet ( id , base ) {
199
199
return {
200
200
base,
201
- content : '@theme {}' ,
201
+ content : css `
202
+ @theme {
203
+ --color-potato : # 7a4724 ;
204
+ }
205
+ ` ,
202
206
}
203
207
} ,
204
208
} )
205
209
206
210
// Prefixed utilities are generated
207
- expect ( compiler . build ( [ 'tw:underline' , 'tw:hover:line-through' , 'tw:custom' ] ) )
208
- . toMatchInlineSnapshot ( `
209
- ".tw\\:custom {
211
+ expect (
212
+ compiler . build ( [
213
+ 'tw:underline' ,
214
+ 'tw:bg-potato' ,
215
+ 'tw:hover:line-through' ,
216
+ 'tw:custom' ,
217
+ 'flex' ,
218
+ 'text-potato' ,
219
+ ] ) ,
220
+ ) . toMatchInlineSnapshot ( `
221
+ ".tw\\:bg-potato {
222
+ background-color: var(--tw-color-potato, #7a4724);
223
+ }
224
+ .tw\\:custom {
210
225
color: red;
211
226
}
212
227
.tw\\:underline {
@@ -227,18 +242,21 @@ test('a prefix can be configured via @import theme(…)', async () => {
227
242
async loadStylesheet ( id , base ) {
228
243
return {
229
244
base,
230
- content : '@theme {}' ,
245
+ content : css `
246
+ @theme {
247
+ --color-potato : # 7a4724 ;
248
+ }
249
+ ` ,
231
250
}
232
251
} ,
233
252
} )
234
253
235
- expect ( compiler . build ( [ 'underline' , 'hover:line-through' , 'custom' ] ) ) . toEqual ( '' )
254
+ expect ( compiler . build ( [ 'underline' , 'hover:line-through' , 'custom' ] ) ) . toMatchInlineSnapshot ( `""` )
236
255
} )
237
256
238
257
test ( 'a prefix can be configured via @import prefix(…)' , async ( ) => {
239
258
let input = css `
240
- @import 'tailwindcss/theme' prefix(tw);
241
- @tailwind utilities;
259
+ @import 'tailwindcss' prefix(tw);
242
260
243
261
@utility custom {
244
262
color : red;
@@ -249,15 +267,25 @@ test('a prefix can be configured via @import prefix(…)', async () => {
249
267
async loadStylesheet ( id , base ) {
250
268
return {
251
269
base,
252
- content : '@theme reference {}' ,
270
+ content : css `
271
+ @theme {
272
+ --color-potato : # 7a4724 ;
273
+ }
274
+ @tailwind utilities;
275
+ ` ,
253
276
}
254
277
} ,
255
278
} )
256
279
257
- // Prefixed utilities are generated
258
- expect ( compiler . build ( [ 'tw:underline' , 'tw:hover:line-through' , 'tw:custom' ] ) )
280
+ expect ( compiler . build ( [ 'tw:underline' , 'tw:bg-potato' , 'tw:hover:line-through' , 'tw:custom' ] ) )
259
281
. toMatchInlineSnapshot ( `
260
- ".tw\\:custom {
282
+ ":root {
283
+ --tw-color-potato: #7a4724;
284
+ }
285
+ .tw\\:bg-potato {
286
+ background-color: var(--tw-color-potato, #7a4724);
287
+ }
288
+ .tw\\:custom {
261
289
color: red;
262
290
}
263
291
.tw\\:underline {
@@ -278,12 +306,22 @@ test('a prefix can be configured via @import prefix(…)', async () => {
278
306
async loadStylesheet ( id , base ) {
279
307
return {
280
308
base,
281
- content : '@theme reference {}' ,
309
+ content : css `
310
+ @theme {
311
+ --color-potato : # 7a4724 ;
312
+ }
313
+ @tailwind utilities;
314
+ ` ,
282
315
}
283
316
} ,
284
317
} )
285
318
286
- expect ( compiler . build ( [ 'underline' , 'hover:line-through' , 'custom' ] ) ) . toEqual ( '' )
319
+ expect ( compiler . build ( [ 'underline' , 'hover:line-through' , 'custom' ] ) ) . toMatchInlineSnapshot ( `
320
+ ":root {
321
+ --tw-color-potato: #7a4724;
322
+ }
323
+ "
324
+ ` )
287
325
} )
288
326
289
327
test ( 'a prefix must be letters only' , async ( ) => {
0 commit comments