File tree 2 files changed +29
-9
lines changed
2 files changed +29
-9
lines changed Original file line number Diff line number Diff line change @@ -151,17 +151,33 @@ describe("Tailwind Variants (TV) - Default", () => {
151
151
color : "red" ,
152
152
class : "bg-red-500" ,
153
153
} ,
154
+ {
155
+ isBig : false ,
156
+ color : "red" ,
157
+ class : "underline" ,
158
+ } ,
154
159
] ,
155
160
} ) ;
156
161
157
- const result = h1 ( {
158
- isBig : true ,
159
- color : "red" ,
160
- } ) ;
162
+ expect (
163
+ h1 ( {
164
+ isBig : true ,
165
+ color : "red" ,
166
+ } ) ,
167
+ ) . toHaveClass ( [ "text-5xl" , "font-bold" , "text-red-500" , "bg-red-500" ] ) ;
161
168
162
- const expectedResult = [ "text-5xl" , "font-bold" , "text-red-500" , "bg-red-500" ] ;
169
+ expect (
170
+ h1 ( {
171
+ isBig : false ,
172
+ color : "red" ,
173
+ } ) ,
174
+ ) . toHaveClass ( [ "text-2xl" , "font-bold" , "text-red-500" , "underline" ] ) ;
163
175
164
- expect ( result ) . toHaveClass ( expectedResult ) ;
176
+ expect (
177
+ h1 ( {
178
+ color : "red" ,
179
+ } ) ,
180
+ ) . toHaveClass ( [ "text-2xl" , "font-bold" , "text-red-500" , "underline" ] ) ;
165
181
} ) ;
166
182
167
183
test ( "should throw error if the compoundVariants is not an array" , ( ) => {
Original file line number Diff line number Diff line change @@ -307,15 +307,19 @@ export const tv = (options, configProp) => {
307
307
let isValid = true ;
308
308
309
309
for ( const [ key , value ] of Object . entries ( compoundVariantOptions ) ) {
310
- const completeProps = getCompleteProps ( key , slotProps ) ;
310
+ const completePropsValue = getCompleteProps ( key , slotProps ) [ key ] ;
311
311
312
312
if ( Array . isArray ( value ) ) {
313
- if ( ! value . includes ( completeProps [ key ] ) ) {
313
+ if ( ! value . includes ( completePropsValue ) ) {
314
314
isValid = false ;
315
315
break ;
316
316
}
317
317
} else {
318
- if ( completeProps [ key ] !== value ) {
318
+ const isBlankOrFalse = ( v ) => v == null || v === false ;
319
+
320
+ if ( isBlankOrFalse ( value ) && isBlankOrFalse ( completePropsValue ) ) continue ;
321
+
322
+ if ( completePropsValue !== value ) {
319
323
isValid = false ;
320
324
break ;
321
325
}
You can’t perform that action at this time.
0 commit comments