Skip to content

Commit 07fc6e3

Browse files
committed
Changes getPercent function
1 parent 3245a61 commit 07fc6e3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/reporters/html-template.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable space-before-function-paren */
22
/* eslint-disable no-control-regex */
3+
import { getPercent } from '../utils/support.mjs'
34
const stripAnsi = (str) => str.replace(/(\x1b|\u001b)\[\d+(?:;\d+)*m/g, '')
45

56
const escapeHtml = (str) => {
@@ -28,7 +29,7 @@ export const template = ({
2829
numTodo = 0,
2930
results,
3031
}) => {
31-
const percent = (v) => (numTests === 0 ? 0 : Math.round((v / numTests) * 100))
32+
const percent = (count) => getPercent(count, numTests)
3233

3334
return `
3435
<!DOCTYPE html>

src/utils/support.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export const timeStamp = () => Date.now()
2+
export const getPercent = (count, total) =>
3+
total === 0 ? 0 : Math.round((count / total) * 100)

0 commit comments

Comments
 (0)