source: trip-planner-front/node_modules/istanbul-reports/lib/html-spa/src/summaryHeader.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

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