* Interpret the results of the tests. * @param {*} results * @param {*} allowlist * @returns {Summary}
(results, allowlist)
| 175 | * @returns {Summary} |
| 176 | */ |
| 177 | interpret(results, allowlist) { |
| 178 | /** |
| 179 | * @type {Summary} |
| 180 | */ |
| 181 | const summary = { |
| 182 | passed: true, |
| 183 | allowed: { |
| 184 | success: [], |
| 185 | failure: [], |
| 186 | falsePositive: [], |
| 187 | falseNegative: [], |
| 188 | }, |
| 189 | disallowed: { |
| 190 | success: [], |
| 191 | failure: [], |
| 192 | falsePositive: [], |
| 193 | falseNegative: [], |
| 194 | }, |
| 195 | unrecognized: [], |
| 196 | count: results.length, |
| 197 | }; |
| 198 | |
| 199 | results.forEach(function (result) { |
| 200 | let classification, isAllowed; |
| 201 | const inAllowlist = allowlist.has(result.id); |
| 202 | allowlist.delete(result.id); |
| 203 | |
| 204 | if (!result.expectedError) { |
| 205 | if (!result.actualError) { |
| 206 | classification = "success"; |
| 207 | isAllowed = !inAllowlist; |
| 208 | } else { |
| 209 | classification = "falseNegative"; |
| 210 | isAllowed = inAllowlist; |
| 211 | } |
| 212 | } else { |
| 213 | if (!result.actualError) { |
| 214 | classification = "falsePositive"; |
| 215 | isAllowed = inAllowlist; |
| 216 | } else { |
| 217 | classification = "failure"; |
| 218 | isAllowed = !inAllowlist; |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | summary.passed &&= isAllowed; |
| 223 | summary[isAllowed ? "allowed" : "disallowed"][classification].push( |
| 224 | result |
| 225 | ); |
| 226 | }); |
| 227 | |
| 228 | summary.unrecognized = Array.from(allowlist); |
| 229 | summary.passed = !!summary.passed && summary.unrecognized.length === 0; |
| 230 | |
| 231 | return summary; |
| 232 | } |
| 233 | |
| 234 | async output(summary) { |