Skip to content

Commit

Permalink
fix: handle different use cases
Browse files Browse the repository at this point in the history
  • Loading branch information
depoulo committed Nov 29, 2023
1 parent e7aee18 commit 118f295
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/__tests__/to-have-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('.toHaveStyle', () => {
)
})

test('handles inline custom properties', () => {
test('handles inline custom properties (with uppercase letters)', () => {
const {queryByTestId} = render(`
<span data-testid="color-example" style="--accentColor: blue">Hello World</span>
`)
Expand Down Expand Up @@ -205,7 +205,7 @@ describe('.toHaveStyle', () => {
<span data-testid="color-example" style="font-size: 12px">Hello World</span>
`)
expect(queryByTestId('color-example')).toHaveStyle({
fontSize: 12
fontSize: 12,
})
})

Expand All @@ -214,7 +214,7 @@ describe('.toHaveStyle', () => {
<span data-testid="color-example" style="font-size: 12rem">Hello World</span>
`)
expect(() => {
expect(queryByTestId('color-example')).toHaveStyle({ fontSize: '12px' })
expect(queryByTestId('color-example')).toHaveStyle({fontSize: '12px'})
}).toThrowError()
})

Expand Down
3 changes: 2 additions & 1 deletion src/to-have-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ function isSubset(styles, computedStyle) {
Object.entries(styles).every(
([prop, value]) =>
computedStyle[prop] === value ||
computedStyle.getPropertyValue(prop) === value,
computedStyle.getPropertyValue(prop) === value ||
computedStyle.getPropertyValue(prop.toLowerCase()) === value,
)
)
}
Expand Down

0 comments on commit 118f295

Please sign in to comment.