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
Try: Make class and style tests less brittle. #26079
Try: Make class and style tests less brittle. #26079
Conversation
Instead of relying on the exact order of classnames and style attributes, split each string into an array and assert that they are equal sets which ignores differences due to order.
|
Similar may be needed in |
| explode( ' ', $expected_classes ), | ||
| explode( ' ', $class_list ) | ||
| ); | ||
| $this->assertEquals( |
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.
I presume this isn't assertEqualSets as foo:bar; foo:bart is not the same as foo:bart; foo:bar. Is that correct?
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.
It was actually unintentional 🤦 sorry about that.
But now that you say that, style property order could matter in some circumstances for things like browser fallbacks. So perhaps it should stay that way?
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.
@TimothyBJacobs Not just browser fallbacks. Although I'd consider it questionable practice, you can do something like padding: 4px; padding-left: 8px, where the left padding will be different depending on the property order.
It looks like |
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.
Confession, I totally read assert_ as test_ and only got it correct because of copy🍝 :)
I presume the assert_styles_and_classes_match is there for anyone using this as a testing library.
LGTM and approving.
|
Thanks for the review @peterwilsoncc! |
Instead of relying on the exact order of classnames and style attributes,
split each string into an array and assert that they are equal sets which
ignores differences due to order.
This hopefully will fix the test failures occurring on
master.