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 => ( ))} ); };