diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2017-11-14 10:38:47 +0000 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2017-11-14 10:38:47 +0000 |
commit | 8902bdec4d54de0e50657c897a9ade413c443924 (patch) | |
tree | ce4a5cb39a477c8c825a43daf01a13b02fd8f357 /spec | |
parent | b79e19d974472a49ff01fbfa95ae83a4fcc91f97 (diff) | |
parent | 476b28a1a28cfbd692c1ccd06f69097cc553e2ef (diff) | |
download | gitlab-ce-8902bdec4d54de0e50657c897a9ade413c443924.tar.gz |
Merge branch '40092-fix-cluster-size' into 'master'
Formats bytes to human readable number in registry table
See merge request gitlab-org/gitlab-ce!15359
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/lib/utils/number_utility_spec.js | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/spec/javascripts/lib/utils/number_utility_spec.js b/spec/javascripts/lib/utils/number_utility_spec.js index 83c92deccdc..fcf27f6805f 100644 --- a/spec/javascripts/lib/utils/number_utility_spec.js +++ b/spec/javascripts/lib/utils/number_utility_spec.js @@ -1,4 +1,4 @@ -import { formatRelevantDigits, bytesToKiB, bytesToMiB } from '~/lib/utils/number_utils'; +import { formatRelevantDigits, bytesToKiB, bytesToMiB, bytesToGiB, numberToHumanSize } from '~/lib/utils/number_utils'; describe('Number Utils', () => { describe('formatRelevantDigits', () => { @@ -52,4 +52,29 @@ describe('Number Utils', () => { expect(bytesToMiB(1000000)).toEqual(0.95367431640625); }); }); + + describe('bytesToGiB', () => { + it('calculates GiB for the given bytes', () => { + expect(bytesToGiB(1073741824)).toEqual(1); + expect(bytesToGiB(10737418240)).toEqual(10); + }); + }); + + describe('numberToHumanSize', () => { + it('should return bytes', () => { + expect(numberToHumanSize(654)).toEqual('654 bytes'); + }); + + it('should return KiB', () => { + expect(numberToHumanSize(1079)).toEqual('1.05 KiB'); + }); + + it('should return MiB', () => { + expect(numberToHumanSize(10485764)).toEqual('10.00 MiB'); + }); + + it('should return GiB', () => { + expect(numberToHumanSize(10737418240)).toEqual('10.00 GiB'); + }); + }); }); |