Skip to content

Add test for validating aria properties for accessibility_requirements #2329

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

Merged
merged 10 commits into from
Jun 26, 2025
Merged
16 changes: 16 additions & 0 deletions __tests__/frontmatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function validateRuleFrontmatter({ frontmatter }, metaData) {
* Check if `accessibility_requirements` (if any) has expected values
*/
if (accessibility_requirements) {
validateAriaProperties(accessibility_requirements)
/**
* The below check the `values` for every `key - value` pair of accessibility requirements
*/
Expand Down Expand Up @@ -123,3 +124,18 @@ function validateGlossaryFrontmatter({ frontmatter }) {
expect(frontmatter).toHaveProperty(requiredProp)
})
}

function validateAriaProperties(accessibilityRequirements) {
const aria12Key = Object.keys(accessibilityRequirements).find(key => key.startsWith('aria12:'))

if (aria12Key) {
// Check that aria key has an anchor name
expect(aria12Key.split(':')[1]).toBeTruthy()

// Check that aria object has the required properties
const requiredAriaProps = ['title', 'forConformance', 'failed', 'passed']
test.each(requiredAriaProps)('has required property `%s`', requiredProp => {
expect(accessibilityRequirements[aria12Key]).toHaveProperty(requiredProp)
})
}
}
Loading