@stryker-mutator/core
Version:
The extendable JavaScript mutation testing framework
40 lines • 1.34 kB
JavaScript
export class TestCoverageTestDouble {
constructor() {
this.testsByMutantId = new Map();
this.testsById = new Map();
this.hitsByMutantId = new Map();
this.staticCoverage = {};
this.hasCoverage = false;
}
hasStaticCoverage(mutantId) {
var _a;
return (_a = this.staticCoverage[mutantId]) !== null && _a !== void 0 ? _a : false;
}
addTest(...testResults) {
for (const testResult of testResults) {
this.testsById.set(testResult.id, testResult);
}
}
addCoverage(mutantId, testIds) {
var _a;
this.hasCoverage = true;
const testResultSet = (_a = this.testsByMutantId.get(mutantId.toString())) !== null && _a !== void 0 ? _a : new Set();
this.testsByMutantId.set(mutantId.toString(), testResultSet);
for (const testId of testIds) {
const test = this.testsById.get(testId);
if (!test) {
throw new Error(`Test ${testId} not found`);
}
testResultSet.add(test);
}
}
forMutant(mutantId) {
return this.testsByMutantId.get(mutantId);
}
clear() {
this.testsById.clear();
this.testsByMutantId.clear();
this.staticCoverage = {};
}
}
//# sourceMappingURL=test-coverage-test-double.js.map