-
Notifications
You must be signed in to change notification settings - Fork 43
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
.toHaveStyle() to support transform styles #26
Conversation
Codecov Report
@@ Coverage Diff @@
## master #26 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 8 8
Lines 92 94 +2
Branches 24 26 +2
=========================================
+ Hits 92 94 +2
Continue to review full report at Codecov.
|
Hi @philipbulley. Thank you for contributing. |
# Conflicts: # README.md # src/__tests__/to-have-style.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you @philipbulley.
They are breaking in master for some unknown reason and we don't need them at all since we can assert the right behavior.
🎉 This PR is included in version 3.4.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
* feat(toHaveStyle): Add ability to assert on transform styles * fix(docs): Change doc block lang to typescript to prevent prettier adding parens
What:
Adds ability for
.toHaveStyle()
to comparetransform
styles.Why:
Previously,
.toHaveStyle()
would only operate on shallow style properties, but transforms are specified as anobject[]
. The transform values would then be compared using strict equality and as such would never pass.Furthermore, the diffs would serialize the transform values as
[object Object]
making both sides appear to be equal.Ultimately, the test would fail regardless but the diff would tell us that everything is fine.
How:
We're now properly handling any style properties with
object[]
values and correctly serializing theexpected
andreceived
passed tojestDiff
. In both cases using recursion to perform the deep checks.Checklist:
docs
I noticed that up until now, there have been no snapshots assertions, but I've added two small snapshots of the
jestDiff
output due to the added complexity in their generation. I think it's important to capture this — hope you don't mind.