From 76cb9c2a39d477a64824a985ade40507e3bbade1 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Fri, 13 Feb 2026 21:34:48 -0800 Subject: feat(vanilla): add testing infrastructure and tests (NK-wjnczv) --- .../lib/html-spa/src/summaryTableLine.js | 159 +++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryTableLine.js (limited to 'vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryTableLine.js') diff --git a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryTableLine.js b/vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryTableLine.js new file mode 100644 index 0000000..6dc56e6 --- /dev/null +++ b/vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryTableLine.js @@ -0,0 +1,159 @@ +const React = require('react'); + +function MetricCells({ metrics }) { + const { classForPercent, pct, covered, missed, total } = metrics; + + return ( + <> + {Math.round(pct)}% + +
+
+
+ + {covered} + {missed} + {total} + + ); +} + +function FileCell({ + file, + prefix, + expandedLines, + setExpandedLines, + hasChildren, + setFileFilter +}) { + if (hasChildren) { + const expandedIndex = expandedLines.indexOf(prefix + file); + const isExpanded = expandedIndex >= 0; + const newExpandedLines = isExpanded + ? [ + ...expandedLines.slice(0, expandedIndex), + ...expandedLines.slice(expandedIndex + 1) + ] + : [...expandedLines, prefix + file]; + + return ( + <> + + setFileFilter(prefix + file)} + > + {file} + + + ); + } else { + return {file}; + } +} + +function getWorstMetricClassForPercent(metricsToShow, metrics) { + let classForPercent = 'none'; + for (const metricToShow in metricsToShow) { + if (metricsToShow[metricToShow]) { + const metricClassForPercent = metrics[metricToShow].classForPercent; + + // ignore none metrics so they don't change whats shown + if (metricClassForPercent === 'none') { + continue; + } + + // if the metric low or lower than whats currently being used, replace it + if ( + metricClassForPercent == 'low' || + (metricClassForPercent === 'medium' && + classForPercent !== 'low') || + (metricClassForPercent === 'high' && + classForPercent !== 'low' && + classForPercent !== 'medium') + ) { + classForPercent = metricClassForPercent; + } + } + } + return classForPercent; +} + +module.exports = function SummaryTableLine({ + prefix, + metrics, + file, + children, + tabSize, + metricsToShow, + expandedLines, + setExpandedLines, + fileFilter, + setFileFilter +}) { + tabSize = tabSize || 0; + if (children && tabSize > 0) { + tabSize--; + } + prefix = (fileFilter ? fileFilter + '/' : '') + (prefix || ''); + + return ( + <> + + + {/* eslint-disable-line prefer-spread */ Array.apply(null, { + length: tabSize + }).map((nothing, index) => ( + + ))} + + + {metricsToShow.statements && ( + + )} + {metricsToShow.branches && ( + + )} + {metricsToShow.functions && ( + + )} + {metricsToShow.lines && } + + {children && + expandedLines.indexOf(prefix + file) >= 0 && + children.map(child => ( + + ))} + + ); +}; -- cgit v1.2.3