Skip to content

feat: to-be-checked and to-be-partially-checked implementation#175

Open
KeylaMunnoz wants to merge 2 commits into
mainfrom
feat/dom-to-be-checked-and-partially-checked
Open

feat: to-be-checked and to-be-partially-checked implementation#175
KeylaMunnoz wants to merge 2 commits into
mainfrom
feat/dom-to-be-checked-and-partially-checked

Conversation

@KeylaMunnoz

Copy link
Copy Markdown
Collaborator

Implementation of both matchers:

  • To be checked
  • To be partially checked

@KeylaMunnoz
KeylaMunnoz requested review from JDOM10 and suany0805 July 7, 2026 19:50

@JDOM10 JDOM10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @KeylaMunnoz! This is looking great, just left a few comments. Let me know what do you think! :shipit:

public toBeChecked(): this {
const isNativeCheckable = isCheckableInput(this.actual);
const isAriaCheckable = isValidAriaChecked(this.actual)
&& ["true", "false"].includes(this.actual.getAttribute("aria-checked") ?? "");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isValidAriaChecked already restricts to "true" | "false" | "mixed", so the ["true", "false"].includes(...) clause makes the helper call redundant — the second check fully covers it. Let's drop one of them (or fold the true/false-only logic into the helper) so the intent is clear.

public toBeChecked(): this {
const isNativeCheckable = isCheckableInput(this.actual);
const isAriaCheckable = isValidAriaChecked(this.actual)
&& ["true", "false"].includes(this.actual.getAttribute("aria-checked") ?? "");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this accepts any element with aria-checked, so a non-widget like would pass. Similar to how toBePressed gates on isButtonElement, we should require a checkable role (checkbox, radio, switch, …) here. Related: the aria-radio-* fixtures are currently unused, so radio-role coverage is missing too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants