getRandomFloat,
getRandomInteger,
hasOwnProp,
+ isArraySorted,
isEmptyArray,
isEmptyObject,
isEmptyString,
isNullOrUndefined,
isObject,
isUndefined,
+ isValidDate,
roundTo,
secureRandom,
sleep,
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);
it('Verify isEmptyObject()', () => {
expect(isEmptyObject({})).toBe(true);
expect(isEmptyObject({ 1: 1, 2: 2 })).toBe(false);
- expect(isEmptyObject(undefined)).toBe(false);
- expect(isEmptyObject(null)).toBe(false);
expect(isEmptyObject(new Map())).toBe(false);
expect(isEmptyObject(new Set())).toBe(false);
expect(isEmptyObject(new WeakMap())).toBe(false);
expect(isEmptyObject(new WeakSet())).toBe(false);
});
+
+ it('Verify isArraySorted()', () => {
+ expect(
+ isArraySorted([], (a, b) => {
+ return a - b;
+ }),
+ ).toBe(true);
+ expect(
+ isArraySorted([1], (a, b) => {
+ return a - b;
+ }),
+ ).toBe(true);
+ expect(isArraySorted<number>([1, 2, 3, 4, 5], (a, b) => a - b)).toBe(true);
+ expect(isArraySorted<number>([1, 2, 3, 5, 4], (a, b) => a - b)).toBe(false);
+ });
});