-
Notifications
You must be signed in to change notification settings - Fork 401
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
Ability to assert mixed-checked checkboxes #243
Comments
Hi! I'd love to take on this one to compensate the fail with the About the matchers I like the idea of having Also, after reading about the "mixed" state I've found out that:
So we should take that into account too. |
Thanks for your input. Yeah, it does not make much sense to add the argument for the other cases. Which makes me think if it makes sense to add it at all. Maybe we should add About the mixed state not supported on a switch, yes, we should take that into account. |
Yeah, I like |
Thanks for your input. Will you take a crack at it with a PR? |
Sure! I'll give it a try |
We can close this right? |
Yup |
Describe the feature you'd like:
See testing-library/eslint-plugin-jest-dom#43
Specifically, the difficulty to asserting that a checkbox-like element is not checked or unchecked, but in a middle third state usually known as "mixed".
Suggested implementation:
It could be a new matcher
toBeCheckedMixed
, but I'm leaning more towards keeping it undertoBeChecked
, which could receive an optional argument'mixed'
(specifically that string, and nothing more), and will pass if the checkbox is in this third state. Without argument it will behave as today. When passed another argument, its behavior is undefined (maybe throw an error? or maybe we should support passing to it'true'
and'false'
and fail or pass accordingly, and still fail with anything else passed to it?)Describe alternatives you've considered:
Keep using
toHaveAttribute('aria-checked', 'mixed')
but in addition to cause the linting issue linked to above, it does not cover the other way in which a checkbox can be mixed-checked:checkboxElement.indeterminate = true
(ref).Teachability, Documentation, Adoption, Migration Strategy:
Add to the documentation the new feature. It does not / should not break existing functionality.
The text was updated successfully, but these errors were encountered: