[6a3a178] | 1 | const React = require('react');
|
---|
| 2 |
|
---|
| 3 | function 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 |
|
---|
| 33 | function 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 |
|
---|
| 45 | module.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 | };
|
---|