Skip to content

Commit

Permalink
fix: Fixes case where s property is greater than 1
Browse files Browse the repository at this point in the history
  • Loading branch information
davelosert committed Nov 2, 2024
1 parent 79d61e6 commit cb83c1a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
20 changes: 20 additions & 0 deletions src/report/getUncoveredLinesFromStatements.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,24 @@ describe("getUncoveredLinesFromStatements()", () => {

expect(uncoveredLines).toEqual([{ start: 1, end: 7 }]);
});

it("handles the case where the property in 's' is greater than 1.", () => {
const statements: StatementCoverageReport = {
statementMap: {
"0": {
start: { line: 1, column: 0 },
end: { line: 1, column: 0 },
},
"1": {
start: { line: 2, column: 0 },
end: { line: 2, column: 0 },
},
},
s: { "0": 2, "1": 8 },
};

const uncoveredLines = getUncoveredLinesFromStatements(statements);

expect(uncoveredLines).toEqual([]);
});
});
4 changes: 1 addition & 3 deletions src/report/getUncoveredLinesFromStatements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ type LineRange = {
end: number;
};

const IS_COVERED = 1;

const getUncoveredLinesFromStatements = ({
s,
statementMap,
Expand All @@ -16,7 +14,7 @@ const getUncoveredLinesFromStatements = ({
const uncoveredLineRanges: LineRange[] = [];
let currentRange: LineRange | undefined = undefined;
for (const key of keys) {
if (s[key] === IS_COVERED) {
if (s[key] > 0) {
// If the statement is covered, we need to close the current range.
if (currentRange) {
uncoveredLineRanges.push(currentRange);
Expand Down

1 comment on commit cb83c1a

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 72.2%
⬆️ +0.25%
634 / 878
🔵 Statements 72.2%
⬆️ +0.25%
634 / 878
🔵 Functions 87.5%
🟰 ±0%
28 / 32
🔵 Branches 96%
⬆️ +0.03%
144 / 150
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/report/getUncoveredLinesFromStatements.ts 100%
🟰 ±0%
100%
🟰 ±0%
100%
🟰 ±0%
100%
🟰 ±0%
Unchanged Files
src/icons.ts 100% 100% 100% 100%
src/index.ts 0% 0% 0% 0% 1-166
src/octokit.ts 0% 0% 0% 0% 1-9
src/writeSummaryToComment.ts 100% 100% 100% 100%
src/writeSummaryToPR.ts 100% 100% 100% 100%
src/inputs/FileCoverageMode.ts 100% 100% 100% 100%
src/inputs/getCommentOn.ts 100% 100% 100% 100%
src/inputs/getCommitSHA.ts 100% 100% 100% 100%
src/inputs/getPullChanges.ts 100% 92.85% 100% 100%
src/inputs/getPullRequestNumber.ts 100% 100% 100% 100%
src/inputs/getViteConfigPath.ts 97.95% 87.5% 100% 97.95% 47
src/inputs/options.ts 0% 0% 0% 0% 1-85
src/inputs/parseCoverageThresholds.ts 100% 100% 100% 100%
src/inputs/parseJsonReports.ts 0% 0% 0% 0% 1-52
src/report/generateCommitSHAUrl.ts 100% 100% 100% 100%
src/report/generateFileCoverageHtml.ts 100% 100% 100% 100%
src/report/generateFileUrl.ts 100% 100% 100% 100%
src/report/generateHeadline.ts 100% 100% 100% 100%
src/report/generateSummaryTableHtml.ts 100% 100% 100% 100%
src/report/getCompareString.ts 100% 100% 100% 100%
Generated in workflow #770 for commit cb83c1a by the Vitest Coverage Report Action

Please sign in to comment.