Skip to content

Commit

Permalink
Format html.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-wiemer committed Oct 10, 2024
1 parent 1173da0 commit 8552a91
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/reporters/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ function HTML(runner, options) {
var progressBar = items[0].getElementsByTagName('progress')[0];
var progressRing = [
items[0].getElementsByClassName('ring-flatlight')[0],
items[0].getElementsByClassName('ring-highlight')[0]];
items[0].getElementsByClassName('ring-highlight')[0]
];
var progressRingRadius = null; // computed CSS unavailable now, so set later
var root = document.getElementById('mocha');

Expand Down Expand Up @@ -233,14 +234,20 @@ function HTML(runner, options) {
);
}
if (progressRing) {
var radius = parseFloat(getComputedStyle(progressRing[0]).getPropertyValue('r'));
var radius = parseFloat(
getComputedStyle(progressRing[0]).getPropertyValue('r')
);
var wholeArc = Math.PI * 2 * radius;
var highlightArc = percent * (wholeArc / 100);
// The progress ring is in 2 parts, the flatlight color and highlight color.
// Rendering both on top of the other, seems to make a 3rd color on the edges.
// To create 1 whole ring with 2 colors, both parts are inverse of the other.
progressRing[0].style['stroke-dasharray'] = `0,${highlightArc}px,${wholeArc}px`;
progressRing[1].style['stroke-dasharray'] = `${highlightArc}px,${wholeArc}px`;
progressRing[0].style[
'stroke-dasharray'
] = `0,${highlightArc}px,${wholeArc}px`;
progressRing[1].style[
'stroke-dasharray'
] = `${highlightArc}px,${wholeArc}px`;
}

// update stats
Expand Down

0 comments on commit 8552a91

Please sign in to comment.