@@ -70,6 +70,7 @@ describe('.toHaveStyle', () => {
70
70
background-color: black;
71
71
color: white;
72
72
float: left;
73
+ --var-name: 0px;
73
74
transition: opacity 0.2s ease-out, top 0.3s cubic-bezier(1.175, 0.885, 0.32, 1.275);
74
75
}
75
76
`
@@ -92,6 +93,11 @@ describe('.toHaveStyle', () => {
92
93
) ,
93
94
) . toThrowError ( )
94
95
96
+ // Custom property names are case sensitive
97
+ expect ( ( ) =>
98
+ expect ( container . querySelector ( '.label' ) ) . toHaveStyle ( '--VAR-NAME: 0px;' ) ,
99
+ ) . toThrowError ( )
100
+
95
101
// Make sure the test fails if the css syntax is not valid
96
102
expect ( ( ) =>
97
103
expect ( container . querySelector ( '.label' ) ) . not . toHaveStyle (
@@ -119,11 +125,11 @@ describe('.toHaveStyle', () => {
119
125
)
120
126
} )
121
127
122
- test ( 'handles inline custom properties' , ( ) => {
128
+ test ( 'handles inline custom properties (with uppercase letters) ' , ( ) => {
123
129
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>
125
131
` )
126
- expect ( queryByTestId ( 'color-example' ) ) . toHaveStyle ( '--color : blue' )
132
+ expect ( queryByTestId ( 'color-example' ) ) . toHaveStyle ( '--accentColor : blue' )
127
133
} )
128
134
129
135
test ( 'handles global custom properties' , ( ) => {
@@ -205,7 +211,7 @@ describe('.toHaveStyle', () => {
205
211
<span data-testid="color-example" style="font-size: 12px">Hello World</span>
206
212
` )
207
213
expect ( queryByTestId ( 'color-example' ) ) . toHaveStyle ( {
208
- fontSize : 12
214
+ fontSize : 12 ,
209
215
} )
210
216
} )
211
217
@@ -214,7 +220,7 @@ describe('.toHaveStyle', () => {
214
220
<span data-testid="color-example" style="font-size: 12rem">Hello World</span>
215
221
` )
216
222
expect ( ( ) => {
217
- expect ( queryByTestId ( 'color-example' ) ) . toHaveStyle ( { fontSize : '12px' } )
223
+ expect ( queryByTestId ( 'color-example' ) ) . toHaveStyle ( { fontSize : '12px' } )
218
224
} ) . toThrowError ( )
219
225
} )
220
226
0 commit comments