diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-05 12:08:55 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-05 12:08:55 +0000 |
commit | fdb953945da752dc52c1957f64a179de39f507e5 (patch) | |
tree | 288f38f5448ffd575dc4361258a0ca91b20f327b /spec/frontend/lib/utils/number_utility_spec.js | |
parent | 77831d580c99993c0367bbb8f2aec373ff09a79a (diff) | |
download | gitlab-ce-fdb953945da752dc52c1957f64a179de39f507e5.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/lib/utils/number_utility_spec.js')
-rw-r--r-- | spec/frontend/lib/utils/number_utility_spec.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/number_utility_spec.js b/spec/frontend/lib/utils/number_utility_spec.js index 2f8f1092612..4dcd9211697 100644 --- a/spec/frontend/lib/utils/number_utility_spec.js +++ b/spec/frontend/lib/utils/number_utility_spec.js @@ -9,6 +9,7 @@ import { median, changeInPercent, formattedChangeInPercent, + isNumeric, } from '~/lib/utils/number_utils'; describe('Number Utils', () => { @@ -162,4 +163,25 @@ describe('Number Utils', () => { expect(formattedChangeInPercent(0, 1, { nonFiniteResult: '*' })).toBe('*'); }); }); + + describe('isNumeric', () => { + it.each` + value | outcome + ${0} | ${true} + ${12345} | ${true} + ${'0'} | ${true} + ${'12345'} | ${true} + ${1.0} | ${true} + ${'1.0'} | ${true} + ${'abcd'} | ${false} + ${'abcd100'} | ${false} + ${''} | ${false} + ${false} | ${false} + ${true} | ${false} + ${undefined} | ${false} + ${null} | ${false} + `('when called with $value it returns $outcome', ({ value, outcome }) => { + expect(isNumeric(value)).toBe(outcome); + }); + }); }); |