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.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/number_utility_spec.js b/spec/frontend/lib/utils/number_utility_spec.js
index 4dcd9211697..f4483f5098b 100644
--- a/spec/frontend/lib/utils/number_utility_spec.js
+++ b/spec/frontend/lib/utils/number_utility_spec.js
@@ -10,6 +10,7 @@ import {
changeInPercent,
formattedChangeInPercent,
isNumeric,
+ isPositiveInteger,
} from '~/lib/utils/number_utils';
describe('Number Utils', () => {
@@ -184,4 +185,29 @@ describe('Number Utils', () => {
expect(isNumeric(value)).toBe(outcome);
});
});
+
+ describe.each`
+ value | outcome
+ ${0} | ${true}
+ ${'0'} | ${true}
+ ${12345} | ${true}
+ ${'12345'} | ${true}
+ ${-1} | ${false}
+ ${'-1'} | ${false}
+ ${1.01} | ${false}
+ ${'1.01'} | ${false}
+ ${'abcd'} | ${false}
+ ${'100abcd'} | ${false}
+ ${'abcd100'} | ${false}
+ ${''} | ${false}
+ ${false} | ${false}
+ ${true} | ${false}
+ ${undefined} | ${false}
+ ${null} | ${false}
+ ${Infinity} | ${false}
+ `('isPositiveInteger', ({ value, outcome }) => {
+ it(`when called with ${typeof value} ${value} it returns ${outcome}`, () => {
+ expect(isPositiveInteger(value)).toBe(outcome);
+ });
+ });
});