styled-components / jest-styled-components

🔧 💅 Jest utilities for Styled Components
MIT License
1.59k stars 145 forks source link

Spaces are not ignored in rgb color #387

Open nkumar-ee opened 3 years ago

nkumar-ee commented 3 years ago

It seems like the spaces are not ignored in colour which is making this test fail. It seems similar to Issue https://github.com/styled-components/jest-styled-components/issues/89

I have tried below

it("should pass but it fails", () => {
  const Wrapper = styled.i`
    > svg {
      fill: rgb(185, 185, 185);
    }
  }
  `
  const Svg = styled.svg``

  const tree = renderer
    .create(
      <Wrapper>
        <Svg />
      </Wrapper>,
    )
    .toJSON()
  expect(tree).toHaveStyleRule("fill", "rgb(185, 185, 185)", { modifier: `> svg` })
})

but it returns with an error

Value mismatch for property 'fill'

    Expected
      "fill: rgb(185, 185, 185)"
    Received:
      "fill: rgb(185,185,185)"
soujvnunes commented 2 years ago

I have facing this false positive as well. One way to get around of it is removing the spaces, like:

  expect(tree).toHaveStyleRule("fill", "rgb(185,185,185)", { modifier: `> svg` })