blob: 3bdd8ffb8c27568611ce4c2024c124773da0e88c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
const React = require('react');
function Ignores({ metrics, metricsToShow }) {
const metricKeys = Object.keys(metricsToShow);
const result = [];
for (let i = 0; i < metricKeys.length; i++) {
const metricKey = metricKeys[i];
if (metricsToShow[metricKey]) {
const skipped = metrics[metricKey].skipped;
if (skipped > 0) {
result.push(
`${skipped} ${metricKey}${
skipped === 1 ? '' : metricKey === 'branch' ? 'es' : 's'
}`
);
}
}
}
if (result.length === 0) {
return false;
}
return (
<div className="toolbar__item">
<span className="strong">{result.join(', ')}</span>
<span className="quiet">Ignored</span>
</div>
);
}
function StatusMetric({ data, name }) {
return (
<div className="toolbar__item">
<span className="strong">{data.pct}%</span>{' '}
<span className="quiet">{name}</span>{' '}
<span className={'fraction ' + data.classForPercent}>
{data.covered}/{data.total}
</span>
</div>
);
}
module.exports = function SummaryHeader({ metrics, metricsToShow }) {
return (
<div className="toolbar">
{metricsToShow.statements && (
<StatusMetric data={metrics.statements} name="Statements" />
)}
{metricsToShow.branches && (
<StatusMetric data={metrics.branches} name="Branches" />
)}
{metricsToShow.functions && (
<StatusMetric data={metrics.functions} name="Functions" />
)}
{metricsToShow.lines && (
<StatusMetric data={metrics.lines} name="Lines" />
)}
<Ignores metrics={metrics} metricsToShow={metricsToShow} />
</div>
);
};
|