From: Jérôme Benoit Date: Tue, 25 Jul 2023 19:38:43 +0000 (+0200) Subject: test: add isValidDate() test X-Git-Tag: v1.2.20~141 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ac8178a44e03ada45311749a741a4661b665a011;p=e-mobility-charging-stations-simulator.git test: add isValidDate() test Signed-off-by: Jérôme Benoit --- diff --git a/test/utils/Utils.test.ts b/test/utils/Utils.test.ts index 233ee75d..5b9f8151 100644 --- a/test/utils/Utils.test.ts +++ b/test/utils/Utils.test.ts @@ -21,6 +21,7 @@ import { isNullOrUndefined, isObject, isUndefined, + isValidDate, roundTo, secureRandom, sleep, @@ -47,6 +48,24 @@ describe('Utils test suite', () => { expect(end - start).toBeGreaterThanOrEqual(1000); }); + it('Verify isValidDate()', () => { + expect(isValidDate(undefined)).toBe(false); + expect(isValidDate(null)).toBe(false); + expect(isValidDate('')).toBe(false); + expect(isValidDate({})).toBe(false); + expect(isValidDate([])).toBe(false); + expect(isValidDate(new Map())).toBe(false); + expect(isValidDate(new Set())).toBe(false); + expect(isValidDate(new WeakMap())).toBe(false); + expect(isValidDate(new WeakSet())).toBe(false); + expect(isValidDate(-1)).toBe(true); + expect(isValidDate(0)).toBe(true); + expect(isValidDate(1)).toBe(true); + expect(isValidDate(-0.5)).toBe(true); + expect(isValidDate(0.5)).toBe(true); + expect(isValidDate(new Date())).toBe(true); + }); + it('Verify convertToDate()', () => { expect(convertToDate(undefined)).toBe(undefined); expect(convertToDate(null)).toBe(null);