jest-styled-components icon indicating copy to clipboard operation
jest-styled-components copied to clipboard

toHaveStyleRule optional 'supports' Option has no effect

Open leotm opened this issue 6 years ago • 0 comments

const Button = styled.button`
  @media (max-width: 640px) {
    &:hover {
      color: red;
    }
  }
`
test('it works', () => {
  const tree = renderer.create(<Button />).toJSON()
  expect(tree).toHaveStyleRule('color', 'red', {
    media: '(max-width:640px)',
    modifier: ':hover',
    supports: '(display: grid)',
  })
})

Should fail with:

No style rules found on passed Component using options
{"media":"(max-width: 640px)","modifier":":hover","supports":"(display: grid)"}

But passes as a false positive.

NB: I'm using mountWithTheme with (ThemeConsumer as any) (because ThemeProvider isn't supported yet) instead of react-test-renderer, but this shouldn't make a difference.

leotm avatar Feb 06 '19 17:02 leotm