diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-14 15:08:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-14 15:08:06 +0300 |
commit | 363a1ea13879c755f9cd8018763d3a7bdf4bf1c7 (patch) | |
tree | 9e96d749ebb984b6650e28e79bb4a87ccf77d998 /spec/frontend/lib | |
parent | 6f9218ac84f0de0ebfddf2d4fbd79db881b2d46a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/lib')
-rw-r--r-- | spec/frontend/lib/utils/number_utility_spec.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/number_utility_spec.js b/spec/frontend/lib/utils/number_utility_spec.js index dc4aa0ea5ed..d2591cd2328 100644 --- a/spec/frontend/lib/utils/number_utility_spec.js +++ b/spec/frontend/lib/utils/number_utility_spec.js @@ -3,6 +3,7 @@ import { bytesToKiB, bytesToMiB, bytesToGiB, + numberToHumanSizeSplit, numberToHumanSize, numberToMetricPrefix, sum, @@ -13,6 +14,12 @@ import { isNumeric, isPositiveInteger, } from '~/lib/utils/number_utils'; +import { + BYTES_FORMAT_BYTES, + BYTES_FORMAT_KIB, + BYTES_FORMAT_MIB, + BYTES_FORMAT_GIB, +} from '~/lib/utils/constants'; describe('Number Utils', () => { describe('formatRelevantDigits', () => { @@ -78,6 +85,28 @@ describe('Number Utils', () => { }); }); + describe('numberToHumanSizeSplit', () => { + it('should return bytes', () => { + expect(numberToHumanSizeSplit(654)).toEqual(['654', BYTES_FORMAT_BYTES]); + expect(numberToHumanSizeSplit(-654)).toEqual(['-654', BYTES_FORMAT_BYTES]); + }); + + it('should return KiB', () => { + expect(numberToHumanSizeSplit(1079)).toEqual(['1.05', BYTES_FORMAT_KIB]); + expect(numberToHumanSizeSplit(-1079)).toEqual(['-1.05', BYTES_FORMAT_KIB]); + }); + + it('should return MiB', () => { + expect(numberToHumanSizeSplit(10485764)).toEqual(['10.00', BYTES_FORMAT_MIB]); + expect(numberToHumanSizeSplit(-10485764)).toEqual(['-10.00', BYTES_FORMAT_MIB]); + }); + + it('should return GiB', () => { + expect(numberToHumanSizeSplit(10737418240)).toEqual(['10.00', BYTES_FORMAT_GIB]); + expect(numberToHumanSizeSplit(-10737418240)).toEqual(['-10.00', BYTES_FORMAT_GIB]); + }); + }); + describe('numberToHumanSize', () => { it('should return bytes', () => { expect(numberToHumanSize(654)).toEqual('654 bytes'); |