Skip to content

Commit

Permalink
fix: Changed .toHaveStyle() to be case-insensitive. (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
connormeredith authored and gnapse committed Oct 31, 2019
1 parent f881e68 commit 9a36d66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/__tests__/to-have-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('.toHaveStyle', () => {
const style = document.createElement('style')
style.innerHTML = `
.label {
align-items: center;
background-color: black;
color: white;
float: left;
Expand Down Expand Up @@ -44,6 +45,10 @@ describe('.toHaveStyle', () => {
color: white;
font-weight: bold;
`)

expect(container.querySelector('.label')).toHaveStyle(`
Align-items: center;
`)
})

test('handles negative test cases', () => {
Expand Down
4 changes: 3 additions & 1 deletion src/to-have-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ function getStyleDeclaration(document, css) {

function isSubset(styles, computedStyle) {
return Object.entries(styles).every(
([prop, value]) => computedStyle.getPropertyValue(prop) === value,
([prop, value]) =>
computedStyle.getPropertyValue(prop.toLowerCase()) ===
value.toLowerCase(),

This comment has been minimized.

Copy link
@joshjg

joshjg Nov 13, 2019

This conversion to lower case is causing issues for us, example which now fails:

expect(element).toHaveStyle("transform: translateX(0);");

Since CSS property values can be case-sensitive, I think this conversion should be removed.

This comment has been minimized.

Copy link
@gnapse

gnapse Nov 14, 2019

Member

Indeed, we're discussing this in #154 (the PR that introduced this issue) and I'm working on a fix.

)
}

Expand Down

0 comments on commit 9a36d66

Please sign in to comment.