aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/jsUtils.test.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/jsUtils.test.ts b/test/jsUtils.test.ts
index a8de4475c..7245d9a68 100644
--- a/test/jsUtils.test.ts
+++ b/test/jsUtils.test.ts
@@ -105,4 +105,26 @@ describe('jsUtils', () => {
105 expect(result).toEqual(false); 105 expect(result).toEqual(false);
106 }); 106 });
107 }); 107 });
108
109 describe('safeParseInt', () => {
110 it('returns zero for undefined', () => {
111 expect(jsUtils.safeParseInt(undefined)).toEqual(0);
112 });
113
114 it('returns zero for null', () => {
115 expect(jsUtils.safeParseInt(null)).toEqual(0);
116 });
117
118 it('parses integer number correctly in beginning of string input', () => {
119 expect(jsUtils.safeParseInt('47.45G')).toEqual(47);
120 });
121
122 it('returns 0 for string input whose starting characters are non-numeric', () => {
123 expect(jsUtils.safeParseInt('G47.45')).toEqual(0);
124 });
125
126 it('parses integer number correctly', () => {
127 expect(jsUtils.safeParseInt(47.45)).toEqual(47);
128 });
129 });
108}); 130});