This commit is contained in:
Родитель
26e585893a
Коммит
ddd9942b0c
|
@ -91,17 +91,15 @@ const Test = ({ row, test, expand, handleTestOnExpand }) => (
|
|||
|
||||
// shows coverage percentage of a file
|
||||
export const CoveragePercentageViewer = ({ coverage }) => {
|
||||
const coveredLines = coverage.coveredLines.length;
|
||||
const totalLines = coveredLines + coverage.uncoveredLines.length;
|
||||
let percentageCovered;
|
||||
if (coveredLines !== 0 || coverage.uncoveredLines.length !== 0) {
|
||||
if (coverage.percentage) {
|
||||
percentageCovered = (
|
||||
<div
|
||||
className="coverage-percentage"
|
||||
style={{ backgroundColor: `${getPercentCovColor(coveredLines / totalLines)}` }}
|
||||
style={{ backgroundColor: `${getPercentCovColor(coverage.percentage)}` }}
|
||||
>
|
||||
{((coveredLines / totalLines) * 100).toPrecision(4)}
|
||||
% - {coveredLines} lines covered out of {totalLines} coverable lines
|
||||
{coverage.percentage.toPrecision(4)}
|
||||
% - {coverage.numCovLines} lines covered out of {coverage.numTotalLines} coverable lines
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -2,6 +2,6 @@ import * as Chroma from 'chroma-js';
|
|||
|
||||
const getPercentCovColor = percent =>
|
||||
// warm red, lemon yellow, neon green
|
||||
Chroma.scale(['#ff4f5e', '#fff44f', '#54ffbd']).mode('lab')(percent);
|
||||
Chroma.scale(['#ff4f5e', '#fff44f', '#54ffbd']).mode('lab')(percent / 100);
|
||||
|
||||
export default getPercentCovColor;
|
||||
|
|
|
@ -63,6 +63,12 @@ export const fileRevisionCoverageSummary = (coverage) => {
|
|||
});
|
||||
});
|
||||
s.uncoveredLines = _.uniq(s.uncoveredLines);
|
||||
// calculate line coverage stats
|
||||
s.numCovLines = s.coveredLines.length;
|
||||
s.numUncovLines = s.uncoveredLines.length;
|
||||
s.numTotalLines = s.numCovLines + s.numUncovLines;
|
||||
s.percentage = (s.numCovLines !== 0 ||
|
||||
s.numUncovLines !== 0) ? ((s.numCovLines / s.numTotalLines) * 100) : undefined;
|
||||
return s;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче