Skip to content

Commit

Permalink
Merge pull request #8 from jussikinnula/add-statement-coverage
Browse files Browse the repository at this point in the history
Add statement coverage into tabulate
  • Loading branch information
romeovs committed Feb 13, 2021
2 parents f94bc69 + 1648857 commit efe537f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/tabulate.js
Expand Up @@ -4,6 +4,7 @@ import { th, tr, td, table, tbody, a, b, span, fragment } from "./html"
export function tabulate(lcov, options) {
const head = tr(
th("File"),
th("Stmts"),
th("Branches"),
th("Funcs"),
th("Lines"),
Expand Down Expand Up @@ -40,9 +41,21 @@ function toFolder(path) {
return tr(td({ colspan: 5 }, b(path)))
}

function getStatement(file) {
const { branches, functions, lines } = file;
return [branches, functions, lines].reduce((prev, curr) => ({
hit: prev.hit + (curr.hit || 0),
found: prev.found + (curr.found || 0),
}), {
hit: 0,
found: 0,
})
}

function toRow(file, indent, options) {
return tr(
td(filename(file, indent, options)),
td(percentage(getStatement(file), options)),
td(percentage(file.branches, options)),
td(percentage(file.functions, options)),
td(percentage(file.lines, options)),
Expand Down

0 comments on commit efe537f

Please sign in to comment.