intern-a11y
Version:
Intern-a11y. An accessibility testing helper for Intern.
46 lines • 1.76 kB
JavaScript
function toA11yResults(axeResults) {
return {
analyzer: 'axe',
source: axeResults.url,
violations: axeResults.violations.map(function (violation) {
var standards = [];
var wcagLevel = '';
if (violation.tags.indexOf('wcag2a') !== -1) {
wcagLevel = 'A';
}
else if (violation.tags.indexOf('wcag2aa') !== -1) {
wcagLevel = 'AA';
}
else if (violation.tags.indexOf('wcag2aaa') !== -1) {
wcagLevel = 'AAA';
}
violation.tags.forEach(function (tag) {
if (/wcag\d+$/.test(tag)) {
var section = tag.slice(4).split('').join('.');
standards.push("Web Content Accessibility Guidelines (WCAG) 2.0, Level " + wcagLevel + ": " + section);
}
else if (/section508\..*/.test(tag)) {
standards.push("Section 508: 1194." + tag.slice('section508.'.length));
}
else if (tag === 'best-practice') {
standards.push('Best practice');
}
else {
standards.push(tag[0].toUpperCase() + tag.slice(1));
}
});
return {
message: violation.help,
snippet: violation.nodes[0].html,
description: violation.description,
target: violation.nodes[0].target[0],
reference: violation.helpUrl,
standards: standards
};
}),
originalResults: axeResults
};
}
exports.toA11yResults = toA11yResults;
//# sourceMappingURL=_axe.js.map
;