diff --git a/frontend/__tests__/units.spec.js b/frontend/__tests__/units.spec.js index 25d263b06f9..d0313813e59 100644 --- a/frontend/__tests__/units.spec.js +++ b/frontend/__tests__/units.spec.js @@ -42,7 +42,7 @@ describe('units', () => { }; test_('banana', 0, '0'); - test_(-1, -1, '-1'); + test_(-1, 0, '0'); test_(-0, -0, '0'); test_(1 / 0, 0, '0'); test_(-1 / 0, 0, '0'); @@ -120,7 +120,7 @@ describe('units', () => { }; test_('banana', '0 B'); - test_(-1, '-1 B'); + test_(-1, '0 B'); test_(-0, '0 B'); test_(1 / 0, '0 B'); test_(-1 / 0, '0 B'); @@ -158,7 +158,7 @@ describe('units', () => { }; test_('banana', '0 B'); - test_(-1, '-1 B'); + test_(-1, '0 B'); test_(-0, '0 B'); test_(1 / 0, '0 B'); test_(-1 / 0, '0 B'); @@ -196,7 +196,7 @@ describe('units', () => { }; test_('banana', '0 i'); - test_(-1, '-1 i'); + test_(-1, '0 i'); test_(-0, '0 i'); test_(1 / 0, '0 i'); test_(-1 / 0, '0 i'); diff --git a/frontend/public/components/utils/units.js b/frontend/public/components/utils/units.js index b9df9fa1693..cf099cf87c9 100644 --- a/frontend/public/components/utils/units.js +++ b/frontend/public/components/utils/units.js @@ -162,7 +162,7 @@ const humanize = (units.humanize = ( ) => { const type = getType(typeName); - if (!isFinite(value)) { + if (!isFinite(value) || value < 0) { value = 0; }