Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
fix scoring logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jalafel committed Nov 21, 2023
1 parent 7b0f991 commit 3fa9f3a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/aggregate-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ const { COLORS } = require("./colors");
const Table = require("cli-table3");

const getTestScore = (results) => {
return results.tests.reduce((acc, { status }) => {
const score = results.tests.reduce((acc, { status }) => {
if (status === "pass") {
return acc + 1;
}
return acc;
}, 0);

return (score / results.tests.length) * (getMaxScore(results) || 1);
};

const getAllMaxScores = (runnerResults) => {
Expand Down Expand Up @@ -63,9 +65,11 @@ function AggregateResults(runnerResults) {
"Total: ",
"----",
"----",
totals.reduce((acc, { score, weight, maxScore }) => {
return acc + (score / (maxScore || 1)) * weight;
}, 0) + "%",
totals
.reduce((acc, { score, weight, maxScore }) => {
return acc + ((score || 0) / (maxScore || 1)) * weight;
}, 0)
.toFixed(2) + "%",
]);
console.log(table.toString());
}
Expand Down

0 comments on commit 3fa9f3a

Please sign in to comment.