Skip to content

Commit

Permalink
refactor: fix undefined StyleSheet.flatten() result handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjastrzebski committed Sep 29, 2022
1 parent 5cf066e commit bb67f0f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/to-have-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export function toHaveStyle(
) {
checkReactElement(element, toHaveStyle, this);

const expected = StyleSheet.flatten(style) as StyleLike;
const received = StyleSheet.flatten(element.props.style) as StyleLike;
const expected = (StyleSheet.flatten(style) ?? {}) as StyleLike;
const received = (StyleSheet.flatten(element.props.style) ?? {}) as StyleLike;

return {
pass: Object.entries(expected).every(([prop, value]) => this.equals(received?.[prop], value)),
Expand Down

0 comments on commit bb67f0f

Please sign in to comment.