diff options
Diffstat (limited to 'spec/frontend/lib/utils/number_utility_spec.js')
-rw-r--r-- | spec/frontend/lib/utils/number_utility_spec.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/number_utility_spec.js b/spec/frontend/lib/utils/number_utility_spec.js index e743678ea90..dc4aa0ea5ed 100644 --- a/spec/frontend/lib/utils/number_utility_spec.js +++ b/spec/frontend/lib/utils/number_utility_spec.js @@ -4,6 +4,7 @@ import { bytesToMiB, bytesToGiB, numberToHumanSize, + numberToMetricPrefix, sum, isOdd, median, @@ -99,6 +100,21 @@ describe('Number Utils', () => { }); }); + describe('numberToMetricPrefix', () => { + it.each` + number | expected + ${123} | ${'123'} + ${1234} | ${'1.2k'} + ${12345} | ${'12.3k'} + ${123456} | ${'123.5k'} + ${1234567} | ${'1.2m'} + ${12345678} | ${'12.3m'} + ${123456789} | ${'123.5m'} + `('returns $expected given $number', ({ number, expected }) => { + expect(numberToMetricPrefix(number)).toBe(expected); + }); + }); + describe('sum', () => { it('should add up two values', () => { expect(sum(1, 2)).toEqual(3); |