Skip to content

Commit

Permalink
fixing wrong tests
Browse files Browse the repository at this point in the history
I'm pretty sure these tests were incorrect and it was just hidden by another bug.

The checkbox role *does* support aria-invalid. So I changed that one to button role, which does not.

Also, the menuitem element (not to be confused with the menuitem role) does not appear at all in the set of elementRoles from aria-query. So I changed that test to use `<a type="command">` instead. The menuitem element is [deprecated and non-standard](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/menuitem).
  • Loading branch information
ef4 committed Jun 16, 2023
1 parent 7b4e9d8 commit 610ed92
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/unit/rules/no-unsupported-role-attributes-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ generateRuleTests({
'<dialog />',
'<a href="#" aria-describedby=""></a>',
'<menu type="toolbar" aria-hidden="true" />',
'<menuitem type="command" aria-labelledby={{this.label}} />',
'<a type="command" aria-labelledby={{this.label}} />',
'<input type="image" aria-atomic />',
'<input type="submit" aria-disabled="true" />',
'<select aria-expanded="false" aria-controls="ctrlID" />',
Expand Down Expand Up @@ -167,46 +167,46 @@ generateRuleTests({
},
},
{
template: '<menuitem type="command" aria-checked={{this.checked}} />',
fixedTemplate: '<menuitem type="command" />',
template: '<a type="command" aria-checked={{this.checked}} />',
fixedTemplate: '<a type="command" />',

verifyResults(results) {
expect(results).toMatchInlineSnapshot(`
[
{
"column": 0,
"endColumn": 57,
"endColumn": 50,
"endLine": 1,
"filePath": "layout.hbs",
"isFixable": true,
"line": 1,
"message": "The attribute aria-checked is not supported by the element menuitem with the implicit role of command",
"message": "The attribute aria-checked is not supported by the element a with the implicit role of generic",
"rule": "no-unsupported-role-attributes",
"severity": 2,
"source": "<menuitem type=\\"command\\" aria-checked={{this.checked}} />",
"source": "<a type=\\"command\\" aria-checked={{this.checked}} />",
},
]
`);
},
},
{
template: '<input type="checkbox" aria-invalid="grammar" />',
fixedTemplate: '<input type="checkbox" />',
template: '<input type="button" aria-invalid="grammar" />',
fixedTemplate: '<input type="button" />',

verifyResults(results) {
expect(results).toMatchInlineSnapshot(`
[
{
"column": 0,
"endColumn": 48,
"endColumn": 46,
"endLine": 1,
"filePath": "layout.hbs",
"isFixable": true,
"line": 1,
"message": "The attribute aria-invalid is not supported by the element input with the implicit role of button",
"rule": "no-unsupported-role-attributes",
"severity": 2,
"source": "<input type=\\"checkbox\\" aria-invalid=\\"grammar\\" />",
"source": "<input type=\\"button\\" aria-invalid=\\"grammar\\" />",
},
]
`);
Expand Down

0 comments on commit 610ed92

Please sign in to comment.