Fix negated ".not" modifier usage edge case #210
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey @MicheleBertoli,
quick PR to fix a small edge case introduced in #206.
This is to fix a scenario which would cause the following test to fail when it shouldn't
Info
Since the
opacity
rule is applied toButton
we can also write a test to check that the rule should not be undefined.I consider this an edge case since this test is certainly convoluted and possibly pointless as most likely if you have a rule applied you want to write a test to check its value.
Fix
When the requested rule is undefined and the expected value is not passed or falsy and the negated
.not
modifier is used then we can return directlyfalse
to make our test pass without any need to use thematcherTest
util which would always return true, since it evaluatesexpect(undefined).toEqual(undefined)
.If the above conditions don't apply then we leave the matching logic to the
matcherTest
util as before.This approach avoid the invocation of a function when is not required (as the result is predictable) and also simplifies the logic as it doesn't require flipping of the assertion.
Notes
.not
modifier with and without values.I actually realised this was probably going to create the issue mentioned above the day after opening #206 but have had a very crazy week and didn't manage to push a fix earlier.
Now that is weekend I finally got 5mins to get this sorted; sorry it will require you to publish v6.3.1 🙏