@@ -24,7 +24,7 @@ class CVATest extends TestCase
24
24
*/
25
25
public function testRecipes (array $ recipe , array $ recipes , string $ expected ): void
26
26
{
27
- $ recipeClass = new CVA ($ recipe ['base ' ] ?? '' , $ recipe ['variants ' ] ?? [], $ recipe ['compounds ' ] ?? []);
27
+ $ recipeClass = new CVA ($ recipe ['base ' ] ?? '' , $ recipe ['variants ' ] ?? [], $ recipe ['compounds ' ] ?? [], $ recipe [ ' defaultVariants ' ] ?? [] );
28
28
29
29
$ this ->assertEquals ($ expected , $ recipeClass ->resolve ($ recipes ));
30
30
}
@@ -230,5 +230,110 @@ public static function recipeProvider(): iterable
230
230
['colors ' => 'primary ' , 'sizes ' => 'sm ' ],
231
231
'font-semibold border rounded text-primary text-sm ' ,
232
232
];
233
+ yield 'default variables ' => [
234
+ [
235
+ 'base ' => 'font-semibold border rounded ' ,
236
+ 'variants ' => [
237
+ 'colors ' => [
238
+ 'primary ' => 'text-primary ' ,
239
+ 'secondary ' => 'text-secondary ' ,
240
+ ],
241
+ 'sizes ' => [
242
+ 'sm ' => 'text-sm ' ,
243
+ 'md ' => 'text-md ' ,
244
+ 'lg ' => 'text-lg ' ,
245
+ ],
246
+ 'rounded ' => [
247
+ 'sm ' => 'rounded-sm ' ,
248
+ 'md ' => 'rounded-md ' ,
249
+ 'lg ' => 'rounded-lg ' ,
250
+ ],
251
+ ],
252
+ 'compounds ' => [
253
+ [
254
+ 'colors ' => ['danger ' , 'secondary ' ],
255
+ 'sizes ' => ['sm ' ],
256
+ 'class ' => 'text-red-500 ' ,
257
+ ],
258
+ ],
259
+ 'defaultVariants ' => [
260
+ 'colors ' => 'primary ' ,
261
+ 'sizes ' => 'sm ' ,
262
+ 'rounded ' => 'md ' ,
263
+ ],
264
+ ],
265
+ ['colors ' => 'primary ' , 'sizes ' => 'sm ' ],
266
+ 'font-semibold border rounded text-primary text-sm rounded-md ' ,
267
+ ];
268
+ yield 'default variables all overwrite ' => [
269
+ [
270
+ 'base ' => 'font-semibold border rounded ' ,
271
+ 'variants ' => [
272
+ 'colors ' => [
273
+ 'primary ' => 'text-primary ' ,
274
+ 'secondary ' => 'text-secondary ' ,
275
+ ],
276
+ 'sizes ' => [
277
+ 'sm ' => 'text-sm ' ,
278
+ 'md ' => 'text-md ' ,
279
+ 'lg ' => 'text-lg ' ,
280
+ ],
281
+ 'rounded ' => [
282
+ 'sm ' => 'rounded-sm ' ,
283
+ 'md ' => 'rounded-md ' ,
284
+ 'lg ' => 'rounded-lg ' ,
285
+ ],
286
+ ],
287
+ 'compounds ' => [
288
+ [
289
+ 'colors ' => ['danger ' , 'secondary ' ],
290
+ 'sizes ' => ['sm ' ],
291
+ 'class ' => 'text-red-500 ' ,
292
+ ],
293
+ ],
294
+ 'defaultVariants ' => [
295
+ 'colors ' => 'primary ' ,
296
+ 'sizes ' => 'sm ' ,
297
+ 'rounded ' => 'md ' ,
298
+ ],
299
+ ],
300
+ ['colors ' => 'primary ' , 'sizes ' => 'sm ' , 'rounded ' => 'lg ' ],
301
+ 'font-semibold border rounded text-primary text-sm rounded-lg ' ,
302
+ ];
303
+ yield 'default variables without matching variants ' => [
304
+ [
305
+ 'base ' => 'font-semibold border rounded ' ,
306
+ 'variants ' => [
307
+ 'colors ' => [
308
+ 'primary ' => 'text-primary ' ,
309
+ 'secondary ' => 'text-secondary ' ,
310
+ ],
311
+ 'sizes ' => [
312
+ 'sm ' => 'text-sm ' ,
313
+ 'md ' => 'text-md ' ,
314
+ 'lg ' => 'text-lg ' ,
315
+ ],
316
+ 'rounded ' => [
317
+ 'sm ' => 'rounded-sm ' ,
318
+ 'md ' => 'rounded-md ' ,
319
+ 'lg ' => 'rounded-lg ' ,
320
+ ],
321
+ ],
322
+ 'compounds ' => [
323
+ [
324
+ 'colors ' => ['danger ' , 'secondary ' ],
325
+ 'sizes ' => ['sm ' ],
326
+ 'class ' => 'text-red-500 ' ,
327
+ ],
328
+ ],
329
+ 'defaultVariants ' => [
330
+ 'colors ' => 'primary ' ,
331
+ 'sizes ' => 'sm ' ,
332
+ 'rounded ' => 'md ' ,
333
+ ],
334
+ ],
335
+ [],
336
+ 'font-semibold border rounded text-primary text-sm rounded-md ' ,
337
+ ];
233
338
}
234
339
}
0 commit comments