Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: toHaveStyle nested arrays #110

Merged
merged 4 commits into from
Sep 15, 2022
Merged

Conversation

felippepuhle
Copy link
Contributor

@felippepuhle felippepuhle commented Sep 9, 2022

What:

Closes #109

Why:

ramda was removed on v4.0.11 which introduced a different behavior compared to what we had in the past, removing the ability of handling nested arrays as the style prop.

How:

Simply replacing mergeAllStyles by StyleSheet.flatten (from react-native itself)

Checklist:

  • Documentation added to the
    docs (N/A)
  • Typescript definitions updated (N/A)
  • Tests
  • Ready to be merged

@codecov
Copy link

codecov bot commented Sep 10, 2022

Codecov Report

Merging #110 (682405b) into main (e628ca0) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #110   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            8         8           
  Lines          151       140   -11     
  Branches        51        44    -7     
=========================================
- Hits           151       140   -11     
Flag Coverage Δ
node-14 100.00% <100.00%> (ø)
node-16 100.00% <100.00%> (ø)
node-18 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/utils.js 100.00% <ø> (ø)
src/to-have-style.js 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@mdjastrzebski mdjastrzebski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. Seems like we could now completely remove mergeAll as it's not used anywhere else.

src/to-have-style.js Show resolved Hide resolved
src/to-have-style.js Outdated Show resolved Hide resolved
src/__tests__/to-have-style.js Show resolved Hide resolved
src/to-have-style.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@mdjastrzebski mdjastrzebski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like I've found an issue with the existing behaviour in isSubset function, please take a look if my reasoning is sound.

Copy link
Collaborator

@mdjastrzebski mdjastrzebski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I've updated the README.md examples to match current behavior.

@mdjastrzebski mdjastrzebski merged commit 044229b into testing-library:main Sep 15, 2022
@github-actions
Copy link

🎉 This PR is included in version 4.0.12 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lokeshdangi
Copy link

lokeshdangi commented Sep 15, 2022

hey. @felippepuhle
why was this test case removed from src/__tests__/to-have-style.js

expect(container).toHaveStyle({ transform: [{ rotate: '45deg' }] });

ideally this should also be present along with

expect(container).toHaveStyle({ transform: [{ scale: 2 }, { rotate: '45deg' }] });

to check if only a certain property in transform is present or not

@felippepuhle
Copy link
Contributor Author

@lokeshdangi I brought up the same topic while changing to the suggested implementation, answer is here: #110 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

toHaveStyle breaks if style is a nested array
3 participants