Merge branch '61910-common_utils_spec-js-fails-locally-on-master-for-roundofffloat' into 'master'
Resolve "common_utils_spec.js fails locally for roundOffFloat" Closes #61910 See merge request gitlab-org/gitlab-ce!28963
This commit is contained in:
commit
f305081c29
1 changed files with 8 additions and 8 deletions
|
@ -852,20 +852,20 @@ describe('common_utils', () => {
|
|||
|
||||
describe('roundOffFloat', () => {
|
||||
it('Rounds off decimal places of a float number with provided precision', () => {
|
||||
expect(commonUtils.roundOffFloat(3.141592, 3)).toBe(3.142);
|
||||
expect(commonUtils.roundOffFloat(3.141592, 3)).toBeCloseTo(3.142);
|
||||
});
|
||||
|
||||
it('Rounds off a float number to a whole number when provided precision is zero', () => {
|
||||
expect(commonUtils.roundOffFloat(3.141592, 0)).toBe(3);
|
||||
expect(commonUtils.roundOffFloat(3.5, 0)).toBe(4);
|
||||
expect(commonUtils.roundOffFloat(3.141592, 0)).toBeCloseTo(3);
|
||||
expect(commonUtils.roundOffFloat(3.5, 0)).toBeCloseTo(4);
|
||||
});
|
||||
|
||||
it('Rounds off float number to nearest 0, 10, 100, 1000 and so on when provided precision is below 0', () => {
|
||||
expect(commonUtils.roundOffFloat(34567.14159, -1)).toBe(34570);
|
||||
expect(commonUtils.roundOffFloat(34567.14159, -2)).toBe(34600);
|
||||
expect(commonUtils.roundOffFloat(34567.14159, -3)).toBe(35000);
|
||||
expect(commonUtils.roundOffFloat(34567.14159, -4)).toBe(30000);
|
||||
expect(commonUtils.roundOffFloat(34567.14159, -5)).toBe(0);
|
||||
expect(commonUtils.roundOffFloat(34567.14159, -1)).toBeCloseTo(34570);
|
||||
expect(commonUtils.roundOffFloat(34567.14159, -2)).toBeCloseTo(34600);
|
||||
expect(commonUtils.roundOffFloat(34567.14159, -3)).toBeCloseTo(35000);
|
||||
expect(commonUtils.roundOffFloat(34567.14159, -4)).toBeCloseTo(30000);
|
||||
expect(commonUtils.roundOffFloat(34567.14159, -5)).toBeCloseTo(0);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue