ember-a11y-testing
Version:
Accessibility testing for Ember applications
24 lines (22 loc) • 909 B
JavaScript
/**
* Formats the axe violation for human consumption
*
* @param {Partial<Result>} violation
* @param {string[]} markup (optional) string of HTML relevant to the violation
*/
function formatViolation(violation, markup) {
if (!violation.impact || !violation.help || !violation.helpUrl) {
throw new Error('formatViolation called with improper structure of parameter: violation. Required properties: impact, help, helpUrl.');
}
let count = 1;
let formattedMarkup = '';
if (markup.length) {
count = markup.length;
formattedMarkup = ` Offending nodes are: \n${markup.join('\n')}`;
}
const plural = count === 1 ? '' : 's';
const violationCount = `Violated ${count} time${plural}.`;
return `[${violation.impact}]: ${violation.help} \n${violationCount}${formattedMarkup}\n${violation.helpUrl}`;
}
export { formatViolation as default };
//# sourceMappingURL=format-violation.js.map