diff --git a/client/app/scripts/utils/__tests__/string-utils-test.js b/client/app/scripts/utils/__tests__/string-utils-test.js index 5b0799a2e..3402d825c 100644 --- a/client/app/scripts/utils/__tests__/string-utils-test.js +++ b/client/app/scripts/utils/__tests__/string-utils-test.js @@ -10,6 +10,12 @@ describe('StringUtils', () => { it('it should render 0', () => { expect(f(0)).toBe('0.00'); }); + + it('it should render get rid of trailing zeros', () => { + expect(f(2104)).toBe('2.104k'); + expect(f(21100)).toBe('21.1k'); + expect(f(2120001)).toBe('2.12M'); + }); }); describe('longestCommonPrefix', () => { diff --git a/client/app/scripts/utils/string-utils.js b/client/app/scripts/utils/string-utils.js index ae3c5974d..b5b17033f 100644 --- a/client/app/scripts/utils/string-utils.js +++ b/client/app/scripts/utils/string-utils.js @@ -5,7 +5,7 @@ import { isoFormat } from 'd3-time-format'; import LCP from 'lcp'; import moment from 'moment'; -const formatLargeValue = d3Format('s'); +const formatLargeValue = d3Format('~s'); function renderHtml(text, unit) {