jest-styled-components
jest-styled-components copied to clipboard
toHaveStyleRule optional 'supports' Option has no effect
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.