@@ -70,6 +70,7 @@ describe('.toHaveStyle', () => {
7070 background-color: black;
7171 color: white;
7272 float: left;
73+ --var-name: 0px;
7374 transition: opacity 0.2s ease-out, top 0.3s cubic-bezier(1.175, 0.885, 0.32, 1.275);
7475 }
7576 `
@@ -92,6 +93,11 @@ describe('.toHaveStyle', () => {
9293 ) ,
9394 ) . toThrowError ( )
9495
96+ // Custom property names are case sensitive
97+ expect ( ( ) =>
98+ expect ( container . querySelector ( '.label' ) ) . toHaveStyle ( '--VAR-NAME: 0px;' ) ,
99+ ) . toThrowError ( )
100+
95101 // Make sure the test fails if the css syntax is not valid
96102 expect ( ( ) =>
97103 expect ( container . querySelector ( '.label' ) ) . not . toHaveStyle (
@@ -119,11 +125,11 @@ describe('.toHaveStyle', () => {
119125 )
120126 } )
121127
122- test ( 'handles inline custom properties' , ( ) => {
128+ test ( 'handles inline custom properties (with uppercase letters) ' , ( ) => {
123129 const { queryByTestId} = render ( `
124- <span data-testid="color-example" style="--color : blue">Hello World</span>
130+ <span data-testid="color-example" style="--accentColor : blue">Hello World</span>
125131 ` )
126- expect ( queryByTestId ( 'color-example' ) ) . toHaveStyle ( '--color : blue' )
132+ expect ( queryByTestId ( 'color-example' ) ) . toHaveStyle ( '--accentColor : blue' )
127133 } )
128134
129135 test ( 'handles global custom properties' , ( ) => {
@@ -205,7 +211,7 @@ describe('.toHaveStyle', () => {
205211 <span data-testid="color-example" style="font-size: 12px">Hello World</span>
206212 ` )
207213 expect ( queryByTestId ( 'color-example' ) ) . toHaveStyle ( {
208- fontSize : 12
214+ fontSize : 12 ,
209215 } )
210216 } )
211217
@@ -214,7 +220,7 @@ describe('.toHaveStyle', () => {
214220 <span data-testid="color-example" style="font-size: 12rem">Hello World</span>
215221 ` )
216222 expect ( ( ) => {
217- expect ( queryByTestId ( 'color-example' ) ) . toHaveStyle ( { fontSize : '12px' } )
223+ expect ( queryByTestId ( 'color-example' ) ) . toHaveStyle ( { fontSize : '12px' } )
218224 } ) . toThrowError ( )
219225 } )
220226
0 commit comments