From b75e0d71a4d270de221b5842f9e06d3335a46601 Mon Sep 17 00:00:00 2001 From: Kevin Miller Date: Thu, 30 Jul 2020 11:43:34 -0700 Subject: [PATCH 1/2] chore: Fix less than zero percent display --- .../pages/race/dashboard/percent.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/components/pages/race/dashboard/percent.js b/src/components/pages/race/dashboard/percent.js index b35a1e394..dbf230786 100644 --- a/src/components/pages/race/dashboard/percent.js +++ b/src/components/pages/race/dashboard/percent.js @@ -2,20 +2,20 @@ import React from 'react' import percentStyles from './percent.module.scss' export default ({ number, highlight }) => { - if (number !== null) { - let percentage = '0' - if (Math.round(number * 100) > 0) { - percentage = number * 100 > 1 ? Math.round(number * 100) : '<1' - } - return ( - <> - {highlight ? ( - {percentage}% - ) : ( - <>{percentage}% - )} - - ) + if (number === null) { + return <>- } - return <>– + let percentage = '0' + if (number > 0) { + percentage = number * 100 > 1 ? Math.round(number * 100) : '<1' + } + return ( + <> + {highlight ? ( + {percentage}% + ) : ( + <>{percentage}% + )} + + ) } From 5f409bbb7ecf98cce72e357fc33989b9251295ba Mon Sep 17 00:00:00 2001 From: Kevin Miller Date: Thu, 30 Jul 2020 11:47:12 -0700 Subject: [PATCH 2/2] chore(test): Update test snapshots --- .../race/dashboard/__snapshots__/breakdown-tables.js.snap | 2 +- .../pages/race/dashboard/__snapshots__/percent.js.snap | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/__tests__/components/pages/race/dashboard/__snapshots__/breakdown-tables.js.snap b/src/__tests__/components/pages/race/dashboard/__snapshots__/breakdown-tables.js.snap index a361eb540..62731d59a 100644 --- a/src/__tests__/components/pages/race/dashboard/__snapshots__/breakdown-tables.js.snap +++ b/src/__tests__/components/pages/race/dashboard/__snapshots__/breakdown-tables.js.snap @@ -132,7 +132,7 @@ exports[`Components : Pages : Race : Dashboard : Ethnicity Table renders correct - 0 + <1 % diff --git a/src/__tests__/components/pages/race/dashboard/__snapshots__/percent.js.snap b/src/__tests__/components/pages/race/dashboard/__snapshots__/percent.js.snap index 47d2bdb10..c3180fd52 100644 --- a/src/__tests__/components/pages/race/dashboard/__snapshots__/percent.js.snap +++ b/src/__tests__/components/pages/race/dashboard/__snapshots__/percent.js.snap @@ -7,7 +7,7 @@ Array [ ] `; -exports[`Components : Race : Dashboard : Percent renders correctly 2`] = `"–"`; +exports[`Components : Race : Dashboard : Percent renders correctly 2`] = `"-"`; exports[`Components : Race : Dashboard : Percent renders correctly 3`] = ` Array [ @@ -18,7 +18,7 @@ Array [ exports[`Components : Race : Dashboard : Percent renders correctly 4`] = ` Array [ - "0", + "<1", "%", ] `;