Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/lib/utils/number_utility_spec.js')
-rw-r--r--spec/frontend/lib/utils/number_utility_spec.js22
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);
+ });
+ });
});