test: add isValidDate() test
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 25 Jul 2023 19:38:43 +0000 (21:38 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 25 Jul 2023 19:38:43 +0000 (21:38 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
test/utils/Utils.test.ts

index 233ee75d8baa886fcdd5e8920d7c58d544095a75..5b9f81515c9686bcbea50afe1b781b3d6c108036 100644 (file)
@@ -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);