From 28892719fb95d5d2a64b17bf378464e0fa0be363 Mon Sep 17 00:00:00 2001 From: Connor Meredith <4907463+connormeredith@users.noreply.github.com> Date: Tue, 29 Oct 2019 07:47:36 +0000 Subject: [PATCH] Changed .toHaveStyle() to be case-insensitive. --- src/__tests__/to-have-style.js | 5 +++++ src/to-have-style.js | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/__tests__/to-have-style.js b/src/__tests__/to-have-style.js index 35b77256..bce75f56 100644 --- a/src/__tests__/to-have-style.js +++ b/src/__tests__/to-have-style.js @@ -12,6 +12,7 @@ describe('.toHaveStyle', () => { const style = document.createElement('style') style.innerHTML = ` .label { + align-items: center; background-color: black; color: white; float: left; @@ -44,6 +45,10 @@ describe('.toHaveStyle', () => { color: white; font-weight: bold; `) + + expect(container.querySelector('.label')).toHaveStyle(` + Align-items: center; + `) }) test('handles negative test cases', () => { diff --git a/src/to-have-style.js b/src/to-have-style.js index 6552f67e..f78272ef 100644 --- a/src/to-have-style.js +++ b/src/to-have-style.js @@ -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(), ) }