From c91f4a466b2f70130ed2a9ae47be7187cf167b93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Matte?= Date: Fri, 30 Dec 2022 13:52:05 -0500 Subject: [PATCH] Extract percent function --- reporter/totalreporter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/reporter/totalreporter.js b/reporter/totalreporter.js index fd276e5..88277de 100644 --- a/reporter/totalreporter.js +++ b/reporter/totalreporter.js @@ -1,5 +1,7 @@ import chalk from 'chalk' +const percentage = (dividend, divisor) => (dividend / divisor * 100).toFixed(0) + const totalreporter = () => { let success = 0, fail = 0, skip = 0 @@ -10,7 +12,7 @@ const totalreporter = () => { msg: () => `${chalk.redBright(`Fail: ${fail}`)} ${chalk.greenBright(`Sucess: ${success}`)} ${chalk.blueBright(`Skip: ${skip}`)} -${chalk.yellowBright(`Ratio: ${(success / (success + fail) * 100).toFixed(0)}%`)}` +${chalk.yellowBright(`Ratio: ${percentage(success, success + fail)}%`)}` } }