tweak in response to reviewer comments

This commit is contained in:
Nick Fyson 2020-09-11 18:25:23 +01:00
parent 88951d6193
commit 1fb7c81099
12 changed files with 40 additions and 52 deletions

View file

@ -17,17 +17,13 @@ ava_1.default('noSourceCodeFound matches against example javascript output', asy
`));
});
function testErrorMatcher(matcherName, logSample) {
const regex = error_matcher_1.namedMatchersForTesting[matcherName] ? error_matcher_1.namedMatchersForTesting[matcherName][1] : null;
if (regex) {
return regex.test(logSample);
if (!(matcherName in error_matcher_1.namedMatchersForTesting)) {
throw new Error(`Unknown matcher ${matcherName}`);
}
else {
if (error_matcher_1.namedMatchersForTesting[matcherName]) {
throw new Error(`Cannot test matcher ${matcherName} with null regex`);
}
else {
throw new Error(`Unknown matcher ${matcherName}`);
}
const regex = error_matcher_1.namedMatchersForTesting[matcherName][1];
if (regex === null) {
throw new Error(`Cannot test matcher ${matcherName} with null regex`);
}
return regex.test(logSample);
}
//# sourceMappingURL=error-matcher.test.js.map