Skip to content
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

Update incorrect tests #2915

Merged
merged 2 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/rules/no-unsupported-role-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function getImplicitRole(element, typeAttribute) {
}
}
}
let implicitRoles = elementRoles.get(elementRoles.keys().find((key) => key.name === element));
const key = elementRoles.keys().find((key) => key.name === element);
const implicitRoles = key && elementRoles.get(key);
return implicitRoles && implicitRoles[0];
}

Expand Down
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 role="menuitem" 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 role="menuitem" aria-checked={{this.checked}} />',
fixedTemplate: '<a role="menuitem" />',

verifyResults(results) {
expect(results).toMatchInlineSnapshot(`
[
{
"column": 0,
"endColumn": 57,
"endColumn": 51,
"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 role menuitem",
"rule": "no-unsupported-role-attributes",
"severity": 2,
"source": "<menuitem type=\\"command\\" aria-checked={{this.checked}} />",
"source": "<a role=\\"menuitem\\" 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