Skip to content
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:'))
Comment thread
zlayaAvocado marked this conversation as resolved.
Outdated

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', 'inapplicable']
Comment thread
zlayaAvocado marked this conversation as resolved.
Outdated
test.each(requiredAriaProps)('has required property `%s`', requiredProp => {
expect(accessibilityRequirements[aria12Key]).toHaveProperty(requiredProp)
})
}
}