-
Notifications
You must be signed in to change notification settings - Fork 412
feat: Add toBeChecked matcher #141
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
Conversation
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.
Thanks for jumping on contributing this.
It is actually a feature that was requested a while ago, and initially dismissed, but recently it turned out we may need it. I do not see you referenced the original issue where it was requested (#107) so that' why I'm giving all this intro.
Your implementation is good, but from that original issue request you can see that this may be helpful also for radio buttons, even if they also have a value
. And most importantly, to make this really useful, it would be great if it also supported custom checkboxes, e.g. something like this:
<div role="checkbox" aria-checked="true|false" />
Do you think you can expand this work to support that (and if we support <input type="radio" />
then we should support custom aria radio buttons as well).
Thanks for the extra info @gnapse, I missed the initial issue. I'm happy to add |
c4ff057
to
867d2b9
Compare
I've added support for |
…o .toBeChecked() matcher.
867d2b9
to
9ee0c05
Compare
@gnapse I've updated with |
🎉 This PR is included in version 4.2.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
@all-contributors please add @connormeredith for code, test, doc |
I've put up a pull request to add @connormeredith! 🎉 |
Given that the goal for extra matchers is readability, I would expect the function to be called |
@michaelmior while I get your point, I'm not sure I agree. Both the api at the native radio button level and the What do you think based on all this? |
That's a fair point. I guess I retract my statement in light of that :) |
Just realized about this matcher was included. It's amazing, thank you! |
Closes #107
What:
Added a
toBeChecked
matcher.Why:
It was not implemented in #90 but I thought it would be a nice addition as there currently isn't a matcher to check the value of a checkbox without it being part of a form.
How:
Implemented along the same lines as
toHaveValue
except it's only limited to<input type="checkbox />
.I wasn't too sure on the best way to handle
<input type="radio" />
as it can be "checked" and also have a "value", so I've left that for now suggesting to usetoHaveFormValue
instead - similar to howtoHaveValue
handles this situation.Checklist: