toHaveStyle breaks if style is a nested array
felippepuhle opened this issue · 2 comments
felippepuhle commented
react-native
orexpo
: react-native@testing-library/react-native
version: 11.0.0jest-preset
: react-nativereact-native
version: 0.68.2node
version: 16
Problem description:
Problem was introduced on v4.0.11, after removing ramda.
Suggested solution:
Keep going deep when merging styles, or maybe using StyleSheet.flatten
Reproduction:
describe('toHaveStyle tests', () => {
it('success', () => {
const { getByText } = render(
<Text style={[{ color: 'blue' }, [{ color: 'red' }]]}>Hey</Text>
)
expect(getByText('Hey')).toHaveStyle({
color: 'red',
})
})
it('fail', () => {
const { getByText } = render(
<Text style={[{ color: 'blue' }, [[{ color: 'red' }]]]}>Hey</Text>
)
expect(getByText('Hey')).toHaveStyle({
color: 'red',
})
})
})
Can you help us fix this issue by submitting a pull request?
I can look at it during my weekends, most likely on the next one
mdjastrzebski commented
@felippepuhle Could you submit a PR, preferably using StyleSheet.flatten?
felippepuhle commented
@felippepuhle Could you submit a PR, preferably using StyleSheet.flatten?
def! I'll push one later