11import React from 'react' ;
2+ import type { CSSPropertiesWithVariables } from '../types' ;
23import { render } from '@testing-library/react' ;
34import { BodyPortal } from './BodyPortal' ;
45import { BodyPortalSlotsContext } from './BodyPortalSlotsContext' ;
@@ -266,7 +267,7 @@ describe('BodyPortal', () => {
266267 render (
267268 < BodyPortal
268269 slot = 'modal'
269- style = { { '--my-variable' : 'red' , '--another-var' : '10px' } as React . CSSProperties }
270+ style = { { '--my-variable' : 'red' , '--another-var' : '10px' } as CSSPropertiesWithVariables }
270271 >
271272 Modal content
272273 </ BodyPortal > ,
@@ -300,7 +301,7 @@ describe('BodyPortal', () => {
300301 const TestComponent = ( { color } : { color : string } ) => (
301302 < BodyPortal
302303 slot = 'modal'
303- style = { { '--color' : color } as React . CSSProperties }
304+ style = { { '--color' : color } as CSSPropertiesWithVariables }
304305 >
305306 Modal content
306307 </ BodyPortal >
@@ -326,7 +327,7 @@ describe('BodyPortal', () => {
326327 const { unmount } = render (
327328 < BodyPortal
328329 slot = 'modal'
329- style = { { '--my-variable' : 'red' , backgroundColor : 'blue' } as React . CSSProperties }
330+ style = { { '--my-variable' : 'red' , backgroundColor : 'blue' } as CSSPropertiesWithVariables }
330331 >
331332 Modal content
332333 </ BodyPortal > ,
@@ -344,11 +345,11 @@ describe('BodyPortal', () => {
344345 expect ( document . body . querySelector ( '[data-portal-slot="modal"]' ) ) . toBeNull ( ) ;
345346 } ) ;
346347
347- it ( 'handles null and undefined style values gracefully' , ( ) => {
348+ it ( 'handles undefined style values gracefully' , ( ) => {
348349 render (
349350 < BodyPortal
350351 slot = 'modal'
351- style = { { '--defined' : 'red' , '--null' : null , '-- undefined' : undefined } as React . CSSProperties }
352+ style = { { '--defined' : 'red' , '--undefined' : undefined } as CSSPropertiesWithVariables }
352353 >
353354 Modal content
354355 </ BodyPortal > ,
@@ -359,7 +360,6 @@ describe('BodyPortal', () => {
359360 expect ( portal ) . toBeTruthy ( ) ;
360361 expect ( portal . style . getPropertyValue ( '--defined' ) ) . toBe ( 'red' ) ;
361362 // null and undefined values should not be set
362- expect ( portal . style . getPropertyValue ( '--null' ) ) . toBe ( '' ) ;
363363 expect ( portal . style . getPropertyValue ( '--undefined' ) ) . toBe ( '' ) ;
364364 } ) ;
365365} ) ;
0 commit comments