clava 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1498 +0,0 @@
1
- import { describe, expect, test, vi } from "vitest";
2
- import {
3
- CONFIGS,
4
- createCVFromConfig,
5
- getConfigDescription,
6
- getConfigMode,
7
- getConfigTransformClass,
8
- getModeComponent,
9
- getStyleClass,
10
- } from "./_utils.ts";
11
-
12
- for (const config of Object.values(CONFIGS)) {
13
- const mode = getConfigMode(config);
14
- const cv = createCVFromConfig(config);
15
- const cls = getConfigTransformClass(config);
16
-
17
- describe(getConfigDescription(config), () => {
18
- test("refine", () => {
19
- const component = getModeComponent(
20
- mode,
21
- cv({
22
- variants: { size: { sm: "sm", lg: "lg" } },
23
- refine: ({ variants }) =>
24
- variants.size === "lg" ? "refine-lg" : null,
25
- }),
26
- );
27
- const props = component({ size: "lg" });
28
- expect(getStyleClass(props)).toEqual({ class: cls("lg refine-lg") });
29
- });
30
-
31
- test("refine with setVariants", () => {
32
- const component = getModeComponent(
33
- mode,
34
- cv({
35
- variants: {
36
- size: { sm: "sm", lg: "lg" },
37
- color: { red: "red", blue: "blue" },
38
- },
39
- refine: ({ variants, setVariants }) => {
40
- if (variants.size === "lg") {
41
- setVariants({ color: "red" });
42
- }
43
- },
44
- }),
45
- );
46
- const props = component({ size: "lg" });
47
- expect(getStyleClass(props)).toEqual({ class: cls("lg red") });
48
- });
49
-
50
- test("refine re-runs when it changes variants", () => {
51
- const component = getModeComponent(
52
- mode,
53
- cv({
54
- variants: {
55
- size: { sm: "sm", lg: "lg" },
56
- color: { red: "red", blue: "blue" },
57
- },
58
- refine: ({ variants, setVariants, addClass }) => {
59
- if (variants.size === "lg") {
60
- setVariants({ color: "red" });
61
- }
62
- if (variants.color === "red") {
63
- addClass("refine-red");
64
- }
65
- },
66
- }),
67
- );
68
- const props = component({ size: "lg" });
69
- expect(getStyleClass(props)).toEqual({
70
- class: cls("lg red refine-red"),
71
- });
72
- });
73
-
74
- test("refine re-runs when computed defaultVariants change variants", () => {
75
- const component = getModeComponent(
76
- mode,
77
- cv({
78
- variants: {
79
- size: { sm: "sm", lg: "lg" },
80
- color: { red: "red", blue: "blue" },
81
- },
82
- defaultVariants: {
83
- color: () => "red" as const,
84
- size: (defaultValue, variants) =>
85
- variants.color === "red" ? "lg" : defaultValue,
86
- },
87
- refine: ({ variants, addClass }) => {
88
- if (variants.size === "lg") {
89
- addClass("refine-lg");
90
- }
91
- },
92
- }),
93
- );
94
- const props = component();
95
- expect(getStyleClass(props)).toEqual({
96
- class: cls("lg red refine-lg"),
97
- });
98
- });
99
-
100
- test("refine converges with NaN computed defaultVariants", () => {
101
- using warn = vi.spyOn(console, "warn").mockImplementation(() => {});
102
- const component = getModeComponent(
103
- mode,
104
- cv({
105
- variants: {
106
- value: (value: number) => (Number.isNaN(value) ? "nan" : null),
107
- },
108
- defaultVariants: {
109
- value: () => Number.NaN,
110
- },
111
- refine: ({ variants, addClass }) => {
112
- if (Number.isNaN(variants.value)) {
113
- addClass("refine-nan");
114
- }
115
- },
116
- }),
117
- );
118
-
119
- const props = component();
120
- expect(getStyleClass(props)).toEqual({
121
- class: cls("nan refine-nan"),
122
- });
123
- expect(component.getVariants()).toEqual({ value: Number.NaN });
124
- expect(warn).not.toHaveBeenCalled();
125
- });
126
-
127
- test("computed defaultVariants can clear inherited defaults", () => {
128
- using warn = vi.spyOn(console, "warn").mockImplementation(() => {});
129
- const base = cv({
130
- variants: {
131
- invert: { true: "invert" },
132
- offset: (value: boolean | undefined) =>
133
- value ? "offset" : undefined,
134
- push: (value: number | undefined) =>
135
- value === undefined ? undefined : `push-${value}`,
136
- },
137
- defaultVariants: {
138
- offset: (_, variants) => !variants.invert,
139
- push: (_, variants) => (variants.invert ? 20 : undefined),
140
- },
141
- });
142
- const component = getModeComponent(mode, cv({ extend: [base] }));
143
-
144
- const props = component();
145
- expect(getStyleClass(props)).toEqual({
146
- class: cls("offset"),
147
- });
148
- expect(component.getVariants()).toEqual({
149
- offset: true,
150
- });
151
- expect(warn).not.toHaveBeenCalled();
152
- });
153
-
154
- test("computed defaultVariants use inherited defaults as defaultValue", () => {
155
- using warn = vi.spyOn(console, "warn").mockImplementation(() => {});
156
- const calls = {
157
- layer: 0,
158
- frame: 0,
159
- control: 0,
160
- };
161
- const layer = cv({
162
- variants: {
163
- layer: { true: "layer" },
164
- invert: { true: "invert" },
165
- offset: (value: boolean | undefined) =>
166
- value ? "offset" : undefined,
167
- push: (value: number | undefined) =>
168
- value === undefined ? undefined : `push-${value}`,
169
- },
170
- defaultVariants: {
171
- layer: true,
172
- offset: (defaultValue, variants) => {
173
- calls.layer += 1;
174
- return variants.invert ? false : defaultValue;
175
- },
176
- push: (_, variants) => (variants.invert ? 20 : undefined),
177
- },
178
- });
179
- const frame = cv({
180
- extend: [layer],
181
- variants: {
182
- frame: { true: "frame" },
183
- },
184
- defaultVariants: {
185
- frame: true,
186
- },
187
- refine: () => {
188
- calls.frame += 1;
189
- },
190
- });
191
- const control = cv({
192
- extend: [frame],
193
- variants: {
194
- control: { true: "control" },
195
- },
196
- defaultVariants: {
197
- control: true,
198
- offset: true,
199
- },
200
- refine: () => {
201
- calls.control += 1;
202
- },
203
- });
204
- const component = getModeComponent(mode, cv({ extend: [control] }));
205
-
206
- const props = component();
207
- expect(getStyleClass(props)).toEqual({
208
- class: cls("layer offset frame control"),
209
- });
210
- expect(component.getVariants()).toEqual({
211
- layer: true,
212
- offset: true,
213
- frame: true,
214
- control: true,
215
- });
216
- expect(calls.layer).toBeGreaterThan(0);
217
- expect(calls.frame).toBeGreaterThan(0);
218
- expect(calls.control).toBeGreaterThan(0);
219
- expect(warn).not.toHaveBeenCalled();
220
- });
221
-
222
- test("computed defaultVariants", () => {
223
- const component = getModeComponent(
224
- mode,
225
- cv({
226
- variants: {
227
- size: { sm: "sm", lg: "lg" },
228
- color: { red: "red", blue: "blue" },
229
- },
230
- defaultVariants: {
231
- color: (defaultValue, variants) =>
232
- variants.size === "lg" ? "red" : defaultValue,
233
- },
234
- }),
235
- );
236
- const props = component({ size: "lg" });
237
- expect(getStyleClass(props)).toEqual({ class: cls("lg red") });
238
- });
239
-
240
- test("computed defaultVariants do not override props", () => {
241
- const component = getModeComponent(
242
- mode,
243
- cv({
244
- variants: {
245
- size: { sm: "sm", lg: "lg" },
246
- color: { red: "red", blue: "blue" },
247
- },
248
- defaultVariants: {
249
- color: () => "red" as const,
250
- },
251
- }),
252
- );
253
- const props = component({ size: "lg", color: "blue" });
254
- expect(getStyleClass(props)).toEqual({ class: cls("lg blue") });
255
- });
256
-
257
- test("computed defaultVariants override extended defaultVariants", () => {
258
- const base = cv({
259
- variants: { color: { red: "red", blue: "blue" } },
260
- defaultVariants: { color: "red" },
261
- });
262
- const component = getModeComponent(
263
- mode,
264
- cv({
265
- extend: [base],
266
- variants: { size: { sm: "sm", lg: "lg" } },
267
- defaultVariants: {
268
- size: "sm",
269
- color: () => "blue" as const,
270
- },
271
- }),
272
- );
273
- const props = component();
274
- expect(getStyleClass(props)).toEqual({ class: cls("blue sm") });
275
- });
276
-
277
- test("parent computed defaultVariants can override child defaultVariants", () => {
278
- const base = cv({
279
- variants: { size: { sm: "sm", lg: "lg" } },
280
- defaultVariants: {
281
- size: () => "lg" as const,
282
- },
283
- });
284
- const component = getModeComponent(
285
- mode,
286
- cv({
287
- extend: [base],
288
- variants: { color: { red: "red", blue: "blue" } },
289
- defaultVariants: { size: "sm", color: "red" },
290
- }),
291
- );
292
- const props = component();
293
- expect(getStyleClass(props)).toEqual({ class: cls("lg red") });
294
- });
295
-
296
- test("parent computed defaultVariants can depend on child defaults", () => {
297
- const base = cv({
298
- variants: { size: { sm: "sm", lg: "lg" }, large: "" },
299
- defaultVariants: {
300
- size: (defaultValue, variants) =>
301
- variants.large ? "lg" : defaultValue,
302
- },
303
- });
304
- const component = getModeComponent(
305
- mode,
306
- cv({
307
- extend: [base],
308
- variants: { color: { red: "red", blue: "blue" } },
309
- defaultVariants: { size: "sm", color: "red", large: true },
310
- }),
311
- );
312
- const props = component();
313
- expect(getStyleClass(props)).toEqual({ class: cls("lg red") });
314
- });
315
-
316
- test("computed defaultVariants preserve intermediate defaults", () => {
317
- const parent = cv({
318
- variants: { size: { sm: "sm", lg: "lg" } },
319
- defaultVariants: {
320
- size: (defaultValue, variants) =>
321
- variants.size ? defaultValue : "lg",
322
- },
323
- });
324
- const child = cv({ extend: [parent], defaultVariants: { size: "sm" } });
325
- const component = getModeComponent(mode, cv({ extend: [child] }));
326
- const props = component();
327
- expect(getStyleClass(props)).toEqual({ class: cls("sm") });
328
- });
329
-
330
- test("child computed defaultVariants override parent computed defaultVariants", () => {
331
- const base = cv({
332
- variants: { size: { sm: "sm", lg: "lg" } },
333
- defaultVariants: {
334
- size: () => "lg" as const,
335
- },
336
- });
337
- const component = getModeComponent(
338
- mode,
339
- cv({
340
- extend: [base],
341
- variants: { color: { red: "red", blue: "blue" } },
342
- defaultVariants: {
343
- size: () => "sm" as const,
344
- color: "red",
345
- },
346
- }),
347
- );
348
- const props = component();
349
- expect(getStyleClass(props)).toEqual({ class: cls("sm red") });
350
- });
351
-
352
- test("child computed defaultVariants can preserve parent computed defaultVariants", () => {
353
- const base = cv({
354
- variants: { size: { sm: "sm", lg: "lg" } },
355
- defaultVariants: {
356
- size: () => "lg" as const,
357
- },
358
- });
359
- const component = getModeComponent(
360
- mode,
361
- cv({
362
- extend: [base],
363
- defaultVariants: {
364
- size: (defaultValue) => defaultValue,
365
- },
366
- }),
367
- );
368
- const props = component();
369
- expect(getStyleClass(props)).toEqual({ class: cls("lg") });
370
- expect(component.getVariants()).toEqual({ size: "lg" });
371
- });
372
-
373
- test("refine in extended component does not see foreign variant keys", () => {
374
- const base = cv({
375
- variants: { size: { sm: "sm", lg: "lg" } },
376
- defaultVariants: { size: "sm" },
377
- refine: ({ variants, addClass }) => {
378
- // `color` is added by the parent component below — it must not
379
- // leak into base's `ctx.variants`, whose shape is declared as
380
- // `{ size }` only.
381
- if ("color" in (variants as Record<string, unknown>)) {
382
- addClass("base-saw-foreign");
383
- } else {
384
- addClass("base-no-foreign");
385
- }
386
- },
387
- });
388
- const component = getModeComponent(
389
- mode,
390
- cv({
391
- extend: [base],
392
- variants: { color: { red: "red", blue: "blue" } },
393
- defaultVariants: { size: "sm" },
394
- }),
395
- );
396
- const props = component({ color: "red" });
397
- expect(getStyleClass(props)).toEqual({
398
- class: cls("sm base-no-foreign red"),
399
- });
400
- });
401
-
402
- test("computed defaultVariants in extended component do not branch on foreign variant keys", () => {
403
- const base = cv({
404
- variants: { size: { sm: "sm", lg: "lg" } },
405
- defaultVariants: {
406
- size: (defaultValue, variants) =>
407
- "color" in (variants as Record<string, unknown>)
408
- ? "lg"
409
- : defaultValue,
410
- },
411
- });
412
- const component = getModeComponent(
413
- mode,
414
- cv({
415
- extend: [base],
416
- variants: { color: { red: "red", blue: "blue" } },
417
- defaultVariants: { size: "sm" },
418
- }),
419
- );
420
- const props = component({ color: "red" });
421
- expect(getStyleClass(props)).toEqual({ class: cls("sm red") });
422
- expect(component.getVariants({ color: "red" })).toEqual({
423
- size: "sm",
424
- color: "red",
425
- });
426
- });
427
-
428
- test("child computed defaultVariants receive refined variants from parent", () => {
429
- const base = cv({
430
- variants: { size: { sm: "sm", lg: "lg" }, small: "" },
431
- refine: ({ setVariants }) => {
432
- setVariants({ small: true });
433
- },
434
- });
435
- const component = getModeComponent(
436
- mode,
437
- cv({
438
- extend: [base],
439
- variants: { color: { red: "red", blue: "blue" } },
440
- defaultVariants: {
441
- size: (defaultValue, variants) =>
442
- variants.small ? "sm" : defaultValue,
443
- color: "red",
444
- },
445
- }),
446
- );
447
- const props = component();
448
- expect(getStyleClass(props)).toEqual({ class: cls("sm red") });
449
- });
450
-
451
- test("refine re-runs when base component refine changes variants", () => {
452
- const base = cv({
453
- variants: { size: { sm: "sm", lg: "lg" }, active: "" },
454
- defaultVariants: { size: "sm" },
455
- refine: ({ variants, setVariants }) => {
456
- if (variants.active) {
457
- setVariants({ size: "lg" });
458
- }
459
- },
460
- });
461
- const component = getModeComponent(
462
- mode,
463
- cv({
464
- extend: [base],
465
- variants: { color: { red: "red", blue: "blue" } },
466
- refine: ({ variants, setVariants }) => {
467
- if (variants.size === "lg") {
468
- setVariants({ color: "red" });
469
- }
470
- },
471
- }),
472
- );
473
- const props = component({ active: true });
474
- expect(getStyleClass(props)).toEqual({ class: cls("lg red") });
475
- });
476
-
477
- test("computed defaultVariants work after a setVariants re-run", () => {
478
- const base = cv({
479
- variants: {
480
- size: { sm: "sm", lg: "lg" },
481
- active: "",
482
- mode: { on: "on" },
483
- },
484
- defaultVariants: {
485
- size: (defaultValue, variants) =>
486
- variants.mode === "on" ? "lg" : defaultValue,
487
- },
488
- refine: ({ variants, setVariants }) => {
489
- if (variants.active) {
490
- setVariants({ mode: "on" });
491
- }
492
- },
493
- });
494
- const component = getModeComponent(mode, cv({ extend: [base] }));
495
- const props = component({ active: true });
496
- expect(getStyleClass(props)).toEqual({ class: cls("lg on") });
497
- });
498
-
499
- test("refine setVariants uses the latest pending value", () => {
500
- const component = getModeComponent(
501
- mode,
502
- cv({
503
- variants: { size: { sm: "sm", lg: "lg" } },
504
- defaultVariants: { size: "sm" },
505
- refine: ({ setVariants }) => {
506
- setVariants({ size: "lg" });
507
- setVariants({ size: "sm" });
508
- },
509
- }),
510
- );
511
- const props = component();
512
- expect(getStyleClass(props)).toEqual({ class: cls("sm") });
513
- });
514
-
515
- test("refine setVariants does not mutate props with plain extends", () => {
516
- const base = cv({
517
- variants: { color: { red: "red", blue: "blue" } },
518
- });
519
- const component = getModeComponent(
520
- mode,
521
- cv({
522
- extend: [base],
523
- variants: { active: "" },
524
- refine: ({ variants, setVariants }) => {
525
- if (variants.active) {
526
- setVariants({ color: "red" });
527
- }
528
- },
529
- }),
530
- );
531
- const mutableProps = { active: true };
532
- component(mutableProps);
533
- expect(mutableProps).toEqual({ active: true });
534
-
535
- const frozenProps = Object.freeze({ active: true });
536
- const getProps = () => component(frozenProps);
537
- expect(getProps).not.toThrow();
538
- expect(getStyleClass(getProps())).toEqual({ class: cls("red") });
539
- });
540
-
541
- test("child setVariants keeps overriding base computed defaultVariants across re-runs", () => {
542
- const base = cv({
543
- variants: { color: { red: "red", blue: "blue" } },
544
- defaultVariants: {
545
- color: () => "blue" as const,
546
- },
547
- });
548
- const component = getModeComponent(
549
- mode,
550
- cv({
551
- extend: [base],
552
- variants: { size: { sm: "sm", lg: "lg" } },
553
- defaultVariants: { size: "sm" },
554
- refine: ({ variants, setVariants }) => {
555
- if (variants.size === "sm") {
556
- setVariants({ color: "red" });
557
- }
558
- },
559
- }),
560
- );
561
- const props = component();
562
- expect(getStyleClass(props)).toEqual({ class: cls("red sm") });
563
- });
564
-
565
- test("refine setVariants sticks across computed default re-runs", () => {
566
- const base = cv({
567
- variants: { color: { red: "red", blue: "blue" } },
568
- defaultVariants: {
569
- color: () => "blue" as const,
570
- },
571
- });
572
- const component = getModeComponent(
573
- mode,
574
- cv({
575
- extend: [base],
576
- variants: { color: { red: "", blue: "" }, done: "" },
577
- refine: ({ variants, setVariants }) => {
578
- if (!variants.done) {
579
- setVariants({ color: "red", done: true });
580
- }
581
- },
582
- }),
583
- );
584
- const props = component();
585
- expect(getStyleClass(props)).toEqual({ class: cls("red") });
586
- });
587
-
588
- test("base computed defaultVariants can override child static defaults after a re-run", () => {
589
- const base = cv({
590
- variants: {
591
- size: { sm: "sm", lg: "lg" },
592
- active: "",
593
- mode: { on: "on" },
594
- },
595
- defaultVariants: {
596
- size: (defaultValue, variants) =>
597
- variants.mode === "on" ? "lg" : defaultValue,
598
- },
599
- refine: ({ variants, setVariants }) => {
600
- if (variants.active) {
601
- setVariants({ mode: "on" });
602
- }
603
- },
604
- });
605
- const component = getModeComponent(
606
- mode,
607
- cv({ extend: [base], defaultVariants: { size: "sm" } }),
608
- );
609
- const props = component({ active: true });
610
- expect(getStyleClass(props)).toEqual({ class: cls("lg on") });
611
- });
612
-
613
- test("parent computed defaultVariants fall back to child defaults after a dependency changes", () => {
614
- const layer = cv({
615
- variants: {
616
- a: { one: "one", two: "two" },
617
- b: { true: "b-true", false: "b-false" },
618
- },
619
- defaultVariants: {
620
- b: true,
621
- a: (defaultValue, variants) => (variants.b ? "one" : defaultValue),
622
- },
623
- refine: ({ variants, setVariants }) => {
624
- if (variants.b) {
625
- setVariants({ b: false });
626
- }
627
- },
628
- });
629
- const component = getModeComponent(
630
- mode,
631
- cv({ extend: [layer], defaultVariants: { a: "two" } }),
632
- );
633
- const props = component();
634
- expect(getStyleClass(props)).toEqual({ class: cls("two b-false") });
635
- expect(component.getVariants()).toEqual({ a: "two", b: false });
636
- });
637
-
638
- test("setVariants from earlier extends overrides computed defaultVariants from later extends", () => {
639
- const first = cv({
640
- variants: { color: { red: "first-red", blue: "first-blue" } },
641
- refine: ({ setVariants }) => {
642
- setVariants({ color: "red" });
643
- },
644
- });
645
- const second = cv({
646
- variants: { color: { red: "second-red", blue: "second-blue" } },
647
- defaultVariants: {
648
- color: () => "blue" as const,
649
- },
650
- });
651
- const component = getModeComponent(mode, cv({ extend: [first, second] }));
652
- const props = component();
653
- expect(getStyleClass(props)).toEqual({
654
- class: cls("first-red second-red"),
655
- });
656
- });
657
-
658
- test("computed defaultVariants from later extends apply to final output", () => {
659
- const first = cv({
660
- variants: { color: { red: "first-red", blue: "first-blue" } },
661
- defaultVariants: {
662
- color: () => "red" as const,
663
- },
664
- });
665
- const second = cv({
666
- variants: { color: { red: "second-red", blue: "second-blue" } },
667
- defaultVariants: {
668
- color: () => "blue" as const,
669
- },
670
- });
671
- const component = getModeComponent(mode, cv({ extend: [first, second] }));
672
- const props = component();
673
- expect(getStyleClass(props)).toEqual({
674
- class: cls("first-blue second-blue"),
675
- });
676
- });
677
-
678
- test("computed defaultVariants do not override stable setVariants on later passes", () => {
679
- const base = cv({
680
- variants: { color: { red: "base-red", blue: "base-blue" } },
681
- refine: ({ setVariants }) => {
682
- setVariants({ color: "red" });
683
- },
684
- });
685
- const component = getModeComponent(
686
- mode,
687
- cv({
688
- extend: [base],
689
- variants: { color: { red: "child-red", blue: "child-blue" } },
690
- defaultVariants: {
691
- color: (defaultValue, variants) =>
692
- variants.color === "red" ? "blue" : defaultValue,
693
- },
694
- }),
695
- );
696
- const props = component();
697
- expect(getStyleClass(props)).toEqual({
698
- class: cls("base-red child-red"),
699
- });
700
- });
701
-
702
- test("computed defaultVariants do not override setVariants from a previous pass", () => {
703
- const component = getModeComponent(
704
- mode,
705
- cv({
706
- variants: {
707
- color: { red: "red", blue: "blue" },
708
- done: "",
709
- },
710
- defaultVariants: {
711
- color: (defaultValue, variants) =>
712
- variants.done ? "blue" : defaultValue,
713
- },
714
- refine: ({ variants, setVariants }) => {
715
- if (!variants.done) {
716
- setVariants({ color: "red", done: true });
717
- }
718
- },
719
- }),
720
- );
721
- const props = component();
722
- expect(getStyleClass(props)).toEqual({ class: cls("red") });
723
- });
724
-
725
- test("refine warns when variants keep changing", () => {
726
- using warn = vi.spyOn(console, "warn").mockImplementation(() => {});
727
- const component = getModeComponent(
728
- mode,
729
- cv({
730
- variants: { size: { sm: "sm", lg: "lg" } },
731
- defaultVariants: { size: "sm" },
732
- refine: ({ variants, setVariants }) => {
733
- setVariants({ size: variants.size === "sm" ? "lg" : "sm" });
734
- },
735
- }),
736
- );
737
-
738
- component();
739
- expect(warn).toHaveBeenCalledWith(
740
- expect.stringContaining("Maximum refine iterations exceeded"),
741
- );
742
- });
743
-
744
- test("refine warning is shared across extended components", () => {
745
- using warn = vi.spyOn(console, "warn").mockImplementation(() => {});
746
- const base = cv({
747
- variants: { size: { sm: "sm", lg: "lg" } },
748
- defaultVariants: { size: "sm" },
749
- refine: ({ variants, setVariants }) => {
750
- setVariants({ size: variants.size === "sm" ? "lg" : "sm" });
751
- },
752
- });
753
- const component = getModeComponent(mode, cv({ extend: [base] }));
754
-
755
- component();
756
- expect(warn).toHaveBeenCalledTimes(1);
757
- expect(warn).toHaveBeenCalledWith(
758
- expect.stringContaining("Maximum refine iterations exceeded"),
759
- );
760
- expect(warn).toHaveBeenCalledWith(
761
- expect.stringMatching(
762
- /Variant\(s\) that did not stabilize: [^\n]*\bsize\b/,
763
- ),
764
- );
765
- expect(warn).toHaveBeenCalledWith(
766
- expect.stringMatching(
767
- /Latest variant changes before warning: [^\n]*\bsize: "(sm|lg)" -> "(sm|lg)"/,
768
- ),
769
- );
770
- expect(warn).toHaveBeenCalledWith(
771
- expect.stringContaining("Component created at:"),
772
- );
773
- });
774
-
775
- test("getVariants warns when variants keep changing", () => {
776
- using warn = vi.spyOn(console, "warn").mockImplementation(() => {});
777
- const component = getModeComponent(
778
- mode,
779
- cv({
780
- variants: { size: { sm: "sm", lg: "lg" } },
781
- defaultVariants: { size: "sm" },
782
- refine: ({ variants, setVariants }) => {
783
- setVariants({ size: variants.size === "sm" ? "lg" : "sm" });
784
- },
785
- }),
786
- );
787
-
788
- component.getVariants();
789
- expect(warn).toHaveBeenCalledWith(
790
- expect.stringContaining("Maximum refine iterations exceeded"),
791
- );
792
- expect(warn).toHaveBeenCalledWith(
793
- expect.stringMatching(
794
- /Variant\(s\) that did not stabilize: [^\n]*\bsize\b/,
795
- ),
796
- );
797
- expect(warn).toHaveBeenCalledWith(
798
- expect.stringMatching(
799
- /Latest variant changes before warning: [^\n]*\bsize: "(sm|lg)" -> "(sm|lg)"/,
800
- ),
801
- );
802
- expect(warn).toHaveBeenCalledWith(
803
- expect.stringContaining("Component created at:"),
804
- );
805
- });
806
-
807
- test("refine warning is omitted in production", () => {
808
- using warn = vi.spyOn(console, "warn").mockImplementation(() => {});
809
- vi.stubEnv("NODE_ENV", "production");
810
- const component = getModeComponent(
811
- mode,
812
- cv({
813
- variants: { size: { sm: "sm", lg: "lg" } },
814
- defaultVariants: { size: "sm" },
815
- refine: ({ variants, setVariants }) => {
816
- setVariants({ size: variants.size === "sm" ? "lg" : "sm" });
817
- },
818
- }),
819
- );
820
-
821
- try {
822
- component();
823
- expect(warn).not.toHaveBeenCalled();
824
- } finally {
825
- vi.unstubAllEnvs();
826
- }
827
- });
828
-
829
- test("refine warning names the variant key that did not stabilize", () => {
830
- using warn = vi.spyOn(console, "warn").mockImplementation(() => {});
831
- const component = getModeComponent(
832
- mode,
833
- cv({
834
- variants: {
835
- size: { sm: "sm", lg: "lg" },
836
- color: { red: "red", blue: "blue" },
837
- },
838
- defaultVariants: { size: "sm", color: "red" },
839
- refine: ({ variants, setVariants }) => {
840
- setVariants({ size: variants.size === "sm" ? "lg" : "sm" });
841
- },
842
- }),
843
- );
844
-
845
- component();
846
- expect(warn).toHaveBeenCalledWith(
847
- expect.stringMatching(
848
- /Variant\(s\) that did not stabilize: [^\n]*\bsize\b/,
849
- ),
850
- );
851
- expect(warn).toHaveBeenCalledWith(
852
- expect.not.stringMatching(
853
- /Variant\(s\) that did not stabilize: [^\n]*\bcolor\b/,
854
- ),
855
- );
856
- });
857
-
858
- test("refine warning reports keys that oscillate at different cadences", () => {
859
- using warn = vi.spyOn(console, "warn").mockImplementation(() => {});
860
- // `size` flips every iteration, `color` flips every other iteration, so
861
- // the final pair may agree on one of them — the warning must still name
862
- // both keys because each contributed to a transition.
863
- const component = getModeComponent(
864
- mode,
865
- cv({
866
- variants: {
867
- size: { sm: "sm", lg: "lg" },
868
- color: { red: "red", blue: "blue" },
869
- },
870
- defaultVariants: { size: "sm", color: "red" },
871
- refine: ({ variants, setVariants }) => {
872
- setVariants({
873
- size: variants.size === "sm" ? "lg" : "sm",
874
- color:
875
- variants.size === "sm"
876
- ? variants.color === "red"
877
- ? "blue"
878
- : "red"
879
- : variants.color,
880
- });
881
- },
882
- }),
883
- );
884
-
885
- component();
886
- expect(warn).toHaveBeenCalledWith(
887
- expect.stringMatching(
888
- /Variant\(s\) that did not stabilize: [^\n]*\bsize\b/,
889
- ),
890
- );
891
- expect(warn).toHaveBeenCalledWith(
892
- expect.stringMatching(
893
- /Variant\(s\) that did not stabilize: [^\n]*\bcolor\b/,
894
- ),
895
- );
896
- expect(warn).toHaveBeenCalledWith(
897
- expect.stringMatching(
898
- /Latest variant changes before warning: [^\n]*\bsize\b[^\n]*\bcolor\b/,
899
- ),
900
- );
901
- });
902
-
903
- test("refine warning includes the component creation stack", () => {
904
- using warn = vi.spyOn(console, "warn").mockImplementation(() => {});
905
- const component = getModeComponent(
906
- mode,
907
- cv({
908
- variants: { size: { sm: "sm", lg: "lg" } },
909
- defaultVariants: { size: "sm" },
910
- refine: ({ variants, setVariants }) => {
911
- setVariants({ size: variants.size === "sm" ? "lg" : "sm" });
912
- },
913
- }),
914
- );
915
-
916
- component();
917
- expect(warn).toHaveBeenCalledWith(
918
- expect.stringContaining("Component created at:"),
919
- );
920
- expect(warn).toHaveBeenCalledWith(
921
- expect.stringContaining("refine.test.ts"),
922
- );
923
- expect(warn).toHaveBeenCalledWith(
924
- expect.not.stringContaining("node_modules"),
925
- );
926
- });
927
-
928
- test("refine warning fallback stack skips internal creation frames", () => {
929
- const ErrorWithCaptureStackTrace = Error as ErrorConstructor & {
930
- captureStackTrace?: (
931
- targetObject: object,
932
- constructorOpt?: Function,
933
- ) => void;
934
- };
935
- const captureStackTrace = ErrorWithCaptureStackTrace.captureStackTrace;
936
- Reflect.deleteProperty(ErrorWithCaptureStackTrace, "captureStackTrace");
937
- using warn = vi.spyOn(console, "warn").mockImplementation(() => {});
938
- const component = getModeComponent(
939
- mode,
940
- cv({
941
- variants: { size: { sm: "sm", lg: "lg" } },
942
- defaultVariants: { size: "sm" },
943
- refine: ({ variants, setVariants }) => {
944
- setVariants({ size: variants.size === "sm" ? "lg" : "sm" });
945
- },
946
- }),
947
- );
948
-
949
- try {
950
- component();
951
- expect(warn).toHaveBeenCalledWith(
952
- expect.stringContaining("Component created at:"),
953
- );
954
- expect(warn).toHaveBeenCalledWith(
955
- expect.stringContaining("refine.test.ts"),
956
- );
957
- expect(warn).toHaveBeenCalledWith(
958
- expect.not.stringContaining("captureCreationFrame"),
959
- );
960
- } finally {
961
- if (captureStackTrace) {
962
- ErrorWithCaptureStackTrace.captureStackTrace = captureStackTrace;
963
- }
964
- }
965
- });
966
-
967
- test("refine warning omits the creation stack when cv ran in production", () => {
968
- using warn = vi.spyOn(console, "warn").mockImplementation(() => {});
969
- vi.stubEnv("NODE_ENV", "production");
970
- const component = getModeComponent(
971
- mode,
972
- cv({
973
- variants: { size: { sm: "sm", lg: "lg" } },
974
- defaultVariants: { size: "sm" },
975
- refine: ({ variants, setVariants }) => {
976
- setVariants({ size: variants.size === "sm" ? "lg" : "sm" });
977
- },
978
- }),
979
- );
980
-
981
- try {
982
- vi.unstubAllEnvs();
983
- component();
984
- const message = String(warn.mock.calls.at(-1)?.[0]);
985
- expect(message).toContain("Maximum refine iterations exceeded");
986
- expect(message).not.toContain("Component created at:");
987
- } finally {
988
- vi.unstubAllEnvs();
989
- }
990
- });
991
-
992
- test("computed defaultVariants run when explicitly passing undefined", () => {
993
- const component = getModeComponent(
994
- mode,
995
- cv({
996
- variants: {
997
- size: { sm: "sm", lg: "lg" },
998
- color: { red: "red", blue: "blue" },
999
- },
1000
- defaultVariants: {
1001
- color: () => "red" as const,
1002
- },
1003
- }),
1004
- );
1005
- const props = component({ size: "lg", color: undefined });
1006
- expect(getStyleClass(props)).toEqual({ class: cls("lg red") });
1007
- });
1008
-
1009
- test("refine with defaultVariants", () => {
1010
- const component = getModeComponent(
1011
- mode,
1012
- cv({
1013
- variants: {
1014
- size: { sm: "sm", lg: "lg" },
1015
- color: { red: "red", blue: "blue" },
1016
- },
1017
- defaultVariants: { size: "lg" },
1018
- refine: ({ variants }) =>
1019
- variants.size === "lg" ? "refine-lg" : null,
1020
- }),
1021
- );
1022
- const props = component();
1023
- expect(getStyleClass(props)).toEqual({ class: cls("lg refine-lg") });
1024
- });
1025
-
1026
- test("refine with defaultVariants from extended", () => {
1027
- const base = cv({
1028
- variants: { size: { sm: "sm", lg: "lg" } },
1029
- defaultVariants: { size: "lg" },
1030
- });
1031
- const component = getModeComponent(
1032
- mode,
1033
- cv({
1034
- extend: [base],
1035
- refine: ({ variants }) =>
1036
- variants.size === "lg" ? "refine-lg" : null,
1037
- }),
1038
- );
1039
- const props = component();
1040
- expect(getStyleClass(props)).toEqual({ class: cls("lg refine-lg") });
1041
- });
1042
-
1043
- test("refine from parent receives boolean default value from overridden variant in child", () => {
1044
- const base = cv({
1045
- variants: {
1046
- size: { sm: "sm", lg: "lg" },
1047
- border: { default: "default", true: "border", false: "" },
1048
- },
1049
- defaultVariants: { size: "lg" },
1050
- refine: ({ variants, setVariants }) => {
1051
- expect(variants.border).toBe(false);
1052
- if (!variants.border) {
1053
- setVariants({ size: "sm" });
1054
- }
1055
- },
1056
- });
1057
- const component = getModeComponent(
1058
- mode,
1059
- cv({
1060
- extend: [base],
1061
- variants: {
1062
- border: (_: boolean) => {},
1063
- },
1064
- defaultVariants: { border: false },
1065
- }),
1066
- );
1067
- const props = component();
1068
- expect(getStyleClass(props)).toEqual({ class: cls("sm") });
1069
- });
1070
-
1071
- test("refine from parent receives boolean default value from overridden variant in grandchild", () => {
1072
- const base = cv({
1073
- variants: {
1074
- size: { sm: "sm", lg: "lg" },
1075
- border: { default: "default", true: "border", false: "" },
1076
- },
1077
- defaultVariants: { size: "lg" },
1078
- refine: ({ variants, setVariants }) => {
1079
- expect(variants.border).toBe(false);
1080
- if (!variants.border) {
1081
- setVariants({ size: "sm" });
1082
- }
1083
- },
1084
- });
1085
- const base2 = cv({ extend: [base] });
1086
- const component = getModeComponent(
1087
- mode,
1088
- cv({
1089
- extend: [base2],
1090
- variants: {
1091
- border: (_: boolean) => {},
1092
- },
1093
- defaultVariants: { border: false },
1094
- }),
1095
- );
1096
- const props = component();
1097
- expect(getStyleClass(props)).toEqual({ class: cls("sm") });
1098
- });
1099
-
1100
- test("refine from parent receives false prop from overridden variant in child", () => {
1101
- const base = cv({
1102
- variants: {
1103
- size: { sm: "sm", lg: "lg" },
1104
- border: { default: "default", true: "border", false: "" },
1105
- },
1106
- defaultVariants: { size: "lg" },
1107
- refine: ({ variants, setVariants }) => {
1108
- expect(variants.border).toBe(false);
1109
- if (!variants.border) {
1110
- setVariants({ size: "sm" });
1111
- }
1112
- },
1113
- });
1114
- const component = getModeComponent(
1115
- mode,
1116
- cv({
1117
- extend: [base],
1118
- variants: {
1119
- border: (_: boolean) => {},
1120
- },
1121
- }),
1122
- );
1123
- const props = component({ border: false });
1124
- expect(getStyleClass(props)).toEqual({ class: cls("sm") });
1125
- });
1126
-
1127
- test("refine from parent receives true prop from overridden variant in child", () => {
1128
- const base = cv({
1129
- variants: {
1130
- size: { sm: "sm", lg: "lg" },
1131
- border: { default: "default", true: "border", false: "" },
1132
- },
1133
- defaultVariants: { size: "lg" },
1134
- refine: ({ variants, setVariants }) => {
1135
- expect(variants.border).toBe(true);
1136
- if (variants.border) {
1137
- setVariants({ size: "sm" });
1138
- }
1139
- },
1140
- });
1141
- const component = getModeComponent(
1142
- mode,
1143
- cv({
1144
- extend: [base],
1145
- variants: {
1146
- border: (_: boolean) => {},
1147
- },
1148
- }),
1149
- );
1150
- const props = component({ border: true });
1151
- expect(getStyleClass(props)).toEqual({ class: cls("sm") });
1152
- });
1153
-
1154
- test("refine from parent receives true prop from overridden variant in grandchild", () => {
1155
- const base = cv({
1156
- variants: {
1157
- size: { sm: "sm", lg: "lg" },
1158
- border: { default: "default", true: "border", false: "" },
1159
- },
1160
- defaultVariants: { size: "lg" },
1161
- refine: ({ variants, setVariants }) => {
1162
- expect(variants.border).toBe(true);
1163
- if (variants.border) {
1164
- setVariants({ size: "sm" });
1165
- }
1166
- },
1167
- });
1168
- const base2 = cv({ extend: [base] });
1169
- const component = getModeComponent(
1170
- mode,
1171
- cv({
1172
- extend: [base2],
1173
- variants: {
1174
- border: (_: boolean) => {},
1175
- },
1176
- }),
1177
- );
1178
- const props = component({ border: true });
1179
- expect(getStyleClass(props)).toEqual({ class: cls("sm") });
1180
- });
1181
-
1182
- test("refine with style", () => {
1183
- const component = getModeComponent(
1184
- mode,
1185
- cv({
1186
- variants: { size: { sm: "sm", lg: "lg" } },
1187
- refine: ({ variants }) =>
1188
- variants.size === "lg" ? { style: { fontSize: "20px" } } : null,
1189
- }),
1190
- );
1191
- const props = component({ size: "lg" });
1192
- expect(getStyleClass(props)).toEqual({
1193
- class: cls("lg"),
1194
- fontSize: "20px",
1195
- });
1196
- });
1197
-
1198
- test("refine with class and style", () => {
1199
- const component = getModeComponent(
1200
- mode,
1201
- cv({
1202
- variants: { size: { sm: "sm", lg: "lg" } },
1203
- refine: ({ variants }) =>
1204
- variants.size === "lg"
1205
- ? { class: "refine-lg", style: { fontSize: "20px" } }
1206
- : null,
1207
- }),
1208
- );
1209
- const props = component({ size: "lg" });
1210
- expect(getStyleClass(props)).toEqual({
1211
- class: cls("lg refine-lg"),
1212
- fontSize: "20px",
1213
- });
1214
- });
1215
-
1216
- test("refine style does not accept numbers", () => {
1217
- const component = getModeComponent(
1218
- mode,
1219
- cv({
1220
- variants: { size: { sm: "sm", lg: "lg" } },
1221
- // @ts-expect-error
1222
- refine: ({ variants }) =>
1223
- variants.size === "lg"
1224
- ? {
1225
- class: "refine-lg",
1226
- style: { fontSize: 20 },
1227
- }
1228
- : null,
1229
- }),
1230
- );
1231
- const props = component({ size: "lg" });
1232
- expect(getStyleClass(props)).toEqual({
1233
- class: cls("lg refine-lg"),
1234
- fontSize: expect.toBeOneOf(["20", "20px"]),
1235
- });
1236
- });
1237
-
1238
- test("refine setVariants does not accept invalid keys", () => {
1239
- const component = getModeComponent(
1240
- mode,
1241
- cv({
1242
- variants: { size: { sm: "sm", lg: "lg" } },
1243
- refine: ({ setVariants }) => {
1244
- setVariants({
1245
- // @ts-expect-error
1246
- invalidKey: "value",
1247
- });
1248
- },
1249
- }),
1250
- );
1251
- const props = component({ size: "lg" });
1252
- expect(getStyleClass(props)).toEqual({ class: cls("lg") });
1253
- });
1254
-
1255
- test("refine setVariants does not accept invalid values", () => {
1256
- const component = getModeComponent(
1257
- mode,
1258
- cv({
1259
- variants: { size: { sm: "sm", lg: "lg" } },
1260
- refine: ({ setVariants }) => {
1261
- setVariants({
1262
- // @ts-expect-error invalid value
1263
- size:
1264
- // no error
1265
- "invalid",
1266
- });
1267
- },
1268
- }),
1269
- );
1270
- const props = component({ size: "lg" });
1271
- // Invalid value overrides the valid one, resulting in no match
1272
- expect(getStyleClass(props)).toEqual({ class: "" });
1273
- });
1274
-
1275
- test("refine addClass with string", () => {
1276
- const component = getModeComponent(
1277
- mode,
1278
- cv({
1279
- variants: { size: { sm: "sm", lg: "lg" } },
1280
- refine: ({ variants, addClass }) => {
1281
- if (variants.size === "lg") {
1282
- addClass("added-lg");
1283
- }
1284
- },
1285
- }),
1286
- );
1287
- const props = component({ size: "lg" });
1288
- expect(getStyleClass(props)).toEqual({ class: cls("lg added-lg") });
1289
- });
1290
-
1291
- test("refine addClass with array", () => {
1292
- const component = getModeComponent(
1293
- mode,
1294
- cv({
1295
- variants: { size: { sm: "sm", lg: "lg" } },
1296
- refine: ({ variants, addClass }) => {
1297
- if (variants.size === "lg") {
1298
- addClass(["added-lg", "extra-class"]);
1299
- }
1300
- },
1301
- }),
1302
- );
1303
- const props = component({ size: "lg" });
1304
- expect(getStyleClass(props)).toEqual({
1305
- class: cls("lg added-lg extra-class"),
1306
- });
1307
- });
1308
-
1309
- test("refine addStyle", () => {
1310
- const component = getModeComponent(
1311
- mode,
1312
- cv({
1313
- variants: { size: { sm: "sm", lg: "lg" } },
1314
- refine: ({ variants, addStyle }) => {
1315
- if (variants.size === "lg") {
1316
- addStyle({ fontSize: "20px" });
1317
- }
1318
- },
1319
- }),
1320
- );
1321
- const props = component({ size: "lg" });
1322
- expect(getStyleClass(props)).toEqual({
1323
- class: cls("lg"),
1324
- fontSize: "20px",
1325
- });
1326
- });
1327
-
1328
- test("refine addClass combined with return value", () => {
1329
- const component = getModeComponent(
1330
- mode,
1331
- cv({
1332
- variants: { size: { sm: "sm", lg: "lg" } },
1333
- refine: ({ variants, addClass }) => {
1334
- if (variants.size === "lg") {
1335
- addClass("added-class");
1336
- }
1337
- return "returned-class";
1338
- },
1339
- }),
1340
- );
1341
- const props = component({ size: "lg" });
1342
- expect(getStyleClass(props)).toEqual({
1343
- class: cls("lg added-class returned-class"),
1344
- });
1345
- });
1346
-
1347
- test("refine addStyle combined with return value", () => {
1348
- const component = getModeComponent(
1349
- mode,
1350
- cv({
1351
- variants: { size: { sm: "sm", lg: "lg" } },
1352
- refine: ({ variants, addStyle }) => {
1353
- if (variants.size === "lg") {
1354
- addStyle({ fontSize: "20px" });
1355
- }
1356
- return { style: { backgroundColor: "red" } };
1357
- },
1358
- }),
1359
- );
1360
- const props = component({ size: "lg" });
1361
- expect(getStyleClass(props)).toEqual({
1362
- class: cls("lg"),
1363
- fontSize: "20px",
1364
- backgroundColor: "red",
1365
- });
1366
- });
1367
-
1368
- test("refine addClass and addStyle together", () => {
1369
- const component = getModeComponent(
1370
- mode,
1371
- cv({
1372
- variants: { size: { sm: "sm", lg: "lg" } },
1373
- refine: ({ variants, addClass, addStyle }) => {
1374
- if (variants.size === "lg") {
1375
- addClass("added-lg");
1376
- addStyle({ fontSize: "20px" });
1377
- }
1378
- },
1379
- }),
1380
- );
1381
- const props = component({ size: "lg" });
1382
- expect(getStyleClass(props)).toEqual({
1383
- class: cls("lg added-lg"),
1384
- fontSize: "20px",
1385
- });
1386
- });
1387
-
1388
- test("refine addClass and addStyle with return value", () => {
1389
- const component = getModeComponent(
1390
- mode,
1391
- cv({
1392
- variants: { size: { sm: "sm", lg: "lg" } },
1393
- refine: ({ variants, addClass, addStyle }) => {
1394
- if (variants.size === "lg") {
1395
- addClass("added-lg");
1396
- addStyle({ fontSize: "20px" });
1397
- }
1398
- return {
1399
- class: "returned-class",
1400
- style: { backgroundColor: "red" },
1401
- };
1402
- },
1403
- }),
1404
- );
1405
- const props = component({ size: "lg" });
1406
- expect(getStyleClass(props)).toEqual({
1407
- class: cls("lg added-lg returned-class"),
1408
- fontSize: "20px",
1409
- backgroundColor: "red",
1410
- });
1411
- });
1412
-
1413
- test("refine addClass multiple calls", () => {
1414
- const component = getModeComponent(
1415
- mode,
1416
- cv({
1417
- variants: { size: { sm: "sm", lg: "lg" } },
1418
- refine: ({ variants, addClass }) => {
1419
- if (variants.size === "lg") {
1420
- addClass("first");
1421
- addClass("second");
1422
- addClass("third");
1423
- }
1424
- },
1425
- }),
1426
- );
1427
- const props = component({ size: "lg" });
1428
- expect(getStyleClass(props)).toEqual({
1429
- class: cls("lg first second third"),
1430
- });
1431
- });
1432
-
1433
- test("refine addStyle multiple calls merges styles", () => {
1434
- const component = getModeComponent(
1435
- mode,
1436
- cv({
1437
- variants: { size: { sm: "sm", lg: "lg" } },
1438
- refine: ({ variants, addStyle }) => {
1439
- if (variants.size === "lg") {
1440
- addStyle({ fontSize: "20px" });
1441
- addStyle({ backgroundColor: "red" });
1442
- addStyle({ color: "blue" });
1443
- }
1444
- },
1445
- }),
1446
- );
1447
- const props = component({ size: "lg" });
1448
- expect(getStyleClass(props)).toEqual({
1449
- class: cls("lg"),
1450
- fontSize: "20px",
1451
- backgroundColor: "red",
1452
- color: "blue",
1453
- });
1454
- });
1455
-
1456
- test("refine addStyle later call overrides earlier", () => {
1457
- const component = getModeComponent(
1458
- mode,
1459
- cv({
1460
- variants: { size: { sm: "sm", lg: "lg" } },
1461
- refine: ({ variants, addStyle }) => {
1462
- if (variants.size === "lg") {
1463
- addStyle({ fontSize: "16px" });
1464
- addStyle({ fontSize: "20px" });
1465
- }
1466
- },
1467
- }),
1468
- );
1469
- const props = component({ size: "lg" });
1470
- expect(getStyleClass(props)).toEqual({
1471
- class: cls("lg"),
1472
- fontSize: "20px",
1473
- });
1474
- });
1475
-
1476
- test("refine addStyle does not accept numbers", () => {
1477
- const component = getModeComponent(
1478
- mode,
1479
- cv({
1480
- variants: { size: { sm: "sm", lg: "lg" } },
1481
- refine: ({ variants, addStyle }) => {
1482
- if (variants.size === "lg") {
1483
- addStyle({
1484
- // @ts-expect-error
1485
- fontSize: 20,
1486
- });
1487
- }
1488
- },
1489
- }),
1490
- );
1491
- const props = component({ size: "lg" });
1492
- expect(getStyleClass(props)).toEqual({
1493
- class: cls("lg"),
1494
- fontSize: expect.toBeOneOf(["20", "20px"]),
1495
- });
1496
- });
1497
- });
1498
- }