@qualweb/core
Version:
QualWeb evaluator core engine
54 lines • 2.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tester = void 0;
class Tester {
assertions = new Map();
toExecute = {};
report;
constructor(report) {
this.report = report;
}
configureByPrinciplesAndLevels(principles, levels) {
for (const [key, assertion] of this.assertions) {
if (principles && principles.length !== 0) {
if (levels && levels.length !== 0) {
if (!assertion.hasPrincipleAndLevels(principles, levels)) {
this.toExecute[key] = false;
}
}
else if (!assertion.hasPrincipleAndLevels(principles, ['A', 'AA', 'AAA'])) {
this.toExecute[key] = false;
}
}
else if (levels &&
levels.length !== 0 &&
!assertion.hasPrincipleAndLevels(['Perceivable', 'Operable', 'Understandable', 'Robust'], levels)) {
this.toExecute[key] = false;
}
}
}
configureIncluded(assertions) {
if (this.assertions?.size !== 0 && assertions && assertions.length !== 0) {
const _assertions = assertions?.map((a) => a.toLowerCase().startsWith('qw') ? a.toUpperCase().trim() : a.trim());
for (const [key, assertion] of this.assertions) {
this.toExecute[key] = !!(_assertions?.includes(assertion.getCode()) || _assertions?.includes(assertion.getMapping()));
}
}
}
configureExcluded(assertions) {
if (assertions && assertions.length !== 0) {
const _assertions = assertions.map((a) => (a.toLowerCase().startsWith('qw') ? a.toUpperCase().trim() : a.trim()));
for (const [key, assertion] of this.assertions) {
this.toExecute[key] =
!_assertions.includes(assertion.getCode()) && !_assertions.includes(assertion.getMapping());
}
}
}
resetConfiguration() {
for (const key in this.toExecute ?? {}) {
this.toExecute[key] = true;
}
}
}
exports.Tester = Tester;
//# sourceMappingURL=Tester.js.map