@@ -2647,19 +2647,16 @@ describe("Tailwind Variants (TV) - Required Variants", () => {
26472647 requiredVariants : [ "intent" , "size" ] ,
26482648 } ) ;
26492649
2650- // Should throw when intent is missing
26512650 // @ts -expect-error - Testing runtime error with missing required variant
26522651 expect ( ( ) => button ( { size : "small" } ) ) . toThrow (
26532652 'Missing required variant: "intent". This variant must be provided.' ,
26542653 ) ;
26552654
2656- // Should throw when size is missing
26572655 // @ts -expect-error - Testing runtime error with missing required variant
26582656 expect ( ( ) => button ( { intent : "primary" } ) ) . toThrow (
26592657 'Missing required variant: "size". This variant must be provided.' ,
26602658 ) ;
26612659
2662- // Should throw when both are missing
26632660 expect ( ( ) => button ( ) ) . toThrow (
26642661 'Missing required variant: "intent". This variant must be provided.' ,
26652662 ) ;
@@ -2714,7 +2711,6 @@ describe("Tailwind Variants (TV) - Required Variants", () => {
27142711
27152712 expect ( result1 ) . toBe ( expectedResult1 ) ;
27162713
2717- // Should still throw when required variant is not provided, even with default
27182714 expect ( ( ) => button ( ) ) . toThrow (
27192715 'Missing required variant: "intent". This variant must be provided.' ,
27202716 ) ;
@@ -2747,7 +2743,6 @@ describe("Tailwind Variants (TV) - Required Variants", () => {
27472743 requiredVariants : [ "size" ] ,
27482744 } ) ;
27492745
2750- // Should throw when required variant is missing
27512746 expect ( ( ) => card ( ) ) . toThrow (
27522747 'Missing required variant: "size". This variant must be provided.' ,
27532748 ) ;
@@ -2852,7 +2847,6 @@ describe("Tailwind Variants (TV) - Required Variants", () => {
28522847 requiredVariants : [ "intent" , "size" ] ,
28532848 } ) ;
28542849
2855- // Should throw when required variants from extended component are missing
28562850 // @ts -expect-error - Testing runtime error with missing required variant
28572851 expect ( ( ) => iconButton ( { size : "small" } ) ) . toThrow (
28582852 'Missing required variant: "intent". This variant must be provided.' ,
@@ -2868,4 +2862,22 @@ describe("Tailwind Variants (TV) - Required Variants", () => {
28682862
28692863 expect ( result ) . toBe ( expectedResult ) ;
28702864 } ) ;
2865+
2866+ test ( "should throw error when requiredVariants contains invalid variant names" , ( ) => {
2867+ const button = tv ( {
2868+ base : "font-semibold" ,
2869+ variants : {
2870+ intent : {
2871+ primary : "bg-blue-500" ,
2872+ secondary : "bg-white" ,
2873+ } ,
2874+ } ,
2875+ // @ts -expect-error - Testing runtime error with invalid variant name
2876+ requiredVariants : [ "intent" , "invalidVariant" ] ,
2877+ } ) ;
2878+
2879+ expect ( ( ) => button ( { intent : "primary" } ) ) . toThrow (
2880+ 'Missing required variant: "invalidVariant". This variant must be provided.' ,
2881+ ) ;
2882+ } ) ;
28712883} ) ;
0 commit comments