Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test_runner: pass pad, truncate and coverage as arguments to coverage…
… report getCell
  • Loading branch information
dmnsgn committed Jun 6, 2023
commit dbafa5b47fd6d373c3dbc0870d1d45c07fdf594b
18 changes: 9 additions & 9 deletions lib/internal/test_runner/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ function getCoverageReport(pad, summary, symbol, color, table) {
}


function getCell(string, width, { pad, truncate, coverage }) {
function getCell(string, width, pad, truncate, coverage) {
if (!table) return string;

let result = string;
Expand All @@ -374,9 +374,9 @@ function getCoverageReport(pad, summary, symbol, color, table) {

// Head
if (table) report += addTableLine(prefix, tableWidth);
report += `${prefix}${getCell('file', filePadLength, { pad: StringPrototypePadEnd, truncate: truncateEnd })}${kSeparator}` +
`${ArrayPrototypeJoin(ArrayPrototypeMap(kColumns, (column, i) => getCell(column, columnPadLengths[i], { pad: StringPrototypePadStart })), kSeparator)}${kSeparator}` +
`${getCell('uncovered lines', uncoveredLinesPadLength, { truncate: truncateEnd })}\n`;
report += `${prefix}${getCell('file', filePadLength, StringPrototypePadEnd, truncateEnd)}${kSeparator}` +
`${ArrayPrototypeJoin(ArrayPrototypeMap(kColumns, (column, i) => getCell(column, columnPadLengths[i], StringPrototypePadStart)), kSeparator)}${kSeparator}` +
`${getCell('uncovered lines', uncoveredLinesPadLength, false, truncateEnd)}\n`;
if (table) report += addTableLine(prefix, tableWidth);

// Body
Expand All @@ -392,15 +392,15 @@ function getCoverageReport(pad, summary, symbol, color, table) {
});
fileCoverage /= kColumnsKeys.length;

report += `${prefix}${getCell(relativePath, filePadLength, { pad: StringPrototypePadEnd, truncate: truncateStart, coverage: fileCoverage })}${kSeparator}` +
`${ArrayPrototypeJoin(ArrayPrototypeMap(coverages, (coverage, j) => getCell(NumberPrototypeToFixed(coverage, 2), columnPadLengths[j], { coverage, pad: StringPrototypePadStart })), kSeparator)}${kSeparator}` +
`${getCell(formatUncoveredLines(file.uncoveredLineNumbers, table), uncoveredLinesPadLength, { truncate: truncateEnd })}\n`;
report += `${prefix}${getCell(relativePath, filePadLength, StringPrototypePadEnd, truncateStart, fileCoverage)}${kSeparator}` +
`${ArrayPrototypeJoin(ArrayPrototypeMap(coverages, (coverage, j) => getCell(NumberPrototypeToFixed(coverage, 2), columnPadLengths[j], StringPrototypePadStart, false, coverage)), kSeparator)}${kSeparator}` +
`${getCell(formatUncoveredLines(file.uncoveredLineNumbers, table), uncoveredLinesPadLength, false, truncateEnd)}\n`;
}

// Foot
if (table) report += addTableLine(prefix, tableWidth);
report += `${prefix}${getCell('all files', filePadLength, { pad: StringPrototypePadEnd, truncate: truncateEnd })}${kSeparator}` +
`${ArrayPrototypeJoin(ArrayPrototypeMap(kColumnsKeys, (columnKey, j) => getCell(NumberPrototypeToFixed(summary.totals[columnKey], 2), columnPadLengths[j], { coverage: summary.totals[columnKey], pad: StringPrototypePadStart })), kSeparator)} |\n`;
report += `${prefix}${getCell('all files', filePadLength, StringPrototypePadEnd, truncateEnd)}${kSeparator}` +
`${ArrayPrototypeJoin(ArrayPrototypeMap(kColumnsKeys, (columnKey, j) => getCell(NumberPrototypeToFixed(summary.totals[columnKey], 2), columnPadLengths[j], StringPrototypePadStart, false, summary.totals[columnKey])), kSeparator)} |\n`;
if (table) report += addTableLine(prefix, tableWidth);

report += `${prefix}end of coverage report\n`;
Expand Down