diff options
author | Vijay A <vraravam@users.noreply.github.com> | 2022-12-26 13:26:12 +0530 |
---|---|---|
committer | Vijay A <vraravam@users.noreply.github.com> | 2022-12-26 13:26:12 +0530 |
commit | 5c350b370cbe8430582d25b062c8de19fdec033b (patch) | |
tree | 55db1e27efd7159ea7c4dc42c0e115b531bc3b83 /test/jsUtils.test.ts | |
parent | Upgrade 'nodejs' to '16.19.0' and 'pnpm' to '7.19.0' (diff) | |
download | ferdium-app-5c350b370cbe8430582d25b062c8de19fdec033b.tar.gz ferdium-app-5c350b370cbe8430582d25b062c8de19fdec033b.tar.zst ferdium-app-5c350b370cbe8430582d25b062c8de19fdec033b.zip |
Minor refactoring
Diffstat (limited to 'test/jsUtils.test.ts')
-rw-r--r-- | test/jsUtils.test.ts | 22 |
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 | }); |