Skip to content

Commit ac014c5

Browse files
committed
♻️ make assertion code clearer, add assertion for errors container
1 parent 54c9aba commit ac014c5

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

security/test/test.mjs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,33 @@ async function testJQuery(version, patched, t) {
5555

5656
const d = dom.window.document;
5757

58+
t.equal(d.getElementById('errors').childNodes.length, 0, 'there are no errors');
5859
t.equal(d.querySelector('#loaded-jQuery').textContent, effectiveVersion, `loaded jQuery v${effectiveVersion}`);
5960

6061
for (const cve of cveMap) {
6162
if(cve[1].versions.includes(version)) {
6263
const cveName = `CVE-${cve[0]}`
6364
const status = d.querySelector(`#${cveName} .cve__footer-status`).textContent;
64-
const notReproducible = status.startsWith(`Can't`);
65+
const reproducible = !status.startsWith(`Can't`);
6566

66-
if(notReproducible) {
67-
console.log(chalk.green(`${cveName.padEnd(14)} - ${status}`));
68-
}
69-
else {
67+
if(reproducible) {
7068
console.log(chalk.red(status
7169
.replace('CVE', `${cveName.padEnd(14)} - `)
7270
));
7371
}
72+
else {
73+
console.log(chalk.green(`${cveName.padEnd(14)} - ${status}`));
74+
}
7475

7576
if(patched && patchedVersions.includes(effectiveVersion)) {
76-
t.ok(notReproducible, `${cveName} should be patched in v${effectiveVersion}`);
77+
t.notOk(reproducible, `${cveName} should be patched in v${effectiveVersion}`);
7778
}
7879
else {
7980
if(cve[1].exceptions.includes(version)) {
80-
t.ok(notReproducible, `${cveName} is supposed be reproducible in v${effectiveVersion} according to the CVE but it can't be reproduced`);
81+
t.notOk(reproducible, `${cveName} is supposed be reproducible in v${effectiveVersion} according to the CVE but it can't be reproduced`);
8182
}
8283
else {
83-
t.notOk(notReproducible, `${cveName} should be reproducible in v${effectiveVersion}`);
84+
t.ok(reproducible, `${cveName} should be reproducible in v${effectiveVersion}`);
8485
}
8586
}
8687
}

0 commit comments

Comments
 (0)