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

@ -18,16 +18,12 @@ test('noSourceCodeFound matches against example javascript output', async t => {
function testErrorMatcher(matcherName: string, logSample: string): boolean {
const regex = namedMatchersForTesting[matcherName] ? namedMatchersForTesting[matcherName][1] : null;
if (regex) {
return regex.test(logSample);
} else {
if (namedMatchersForTesting[matcherName]) {
throw new Error(`Cannot test matcher ${matcherName} with null regex`);
} else {
throw new Error(`Unknown matcher ${matcherName}`);
}
if (!(matcherName in namedMatchersForTesting)) {
throw new Error(`Unknown matcher ${matcherName}`);
}
const regex = namedMatchersForTesting[matcherName][1];
if (regex === null) {
throw new Error(`Cannot test matcher ${matcherName} with null regex`);
}
return regex.test(logSample);
}