From 1db8e053e45f98eef5820229ac0a6c1025af9b74 Mon Sep 17 00:00:00 2001 From: Nevio Di Gennaro Date: Mon, 23 Dec 2024 13:57:29 +0100 Subject: [PATCH] replace multiple ifs with one switch --- .../cypress/support/helper/scoringSupport.ts | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/frontend/cypress/support/helper/scoringSupport.ts b/frontend/cypress/support/helper/scoringSupport.ts index 93992f39b2..f78942b5d9 100644 --- a/frontend/cypress/support/helper/scoringSupport.ts +++ b/frontend/cypress/support/helper/scoringSupport.ts @@ -36,19 +36,18 @@ export function getPercentageMetric(baseline: number, stretchGoal: number, value } export function getPercentageOrdinal(zone: string) { - if (zone == 'stretch') { - return 101; + switch (zone) { + case 'fail': + return 30; + case 'commit': + return 70; + case 'target': + return 99.99; + case 'stretch': + return 101; + default: + return 0; } - if (zone == 'target') { - return 99.99; - } - if (zone == 'commit') { - return 70; - } - if (zone == 'fail') { - return 30; - } - return 0; } function validateScoringWidth(zone: string, percent: number, isOverview: boolean) {