UNPKG

@cainiaofe/cn-ui-m

Version:
24 lines (23 loc) 1.08 kB
import { compareTime } from '../index'; describe('compareTime', function () { it('should return true when the second date is after the first date', function () { var dates = [new Date('2022-01-01'), new Date('2022-01-02')]; expect(compareTime(dates)).toBe(true); }); it('should return true when the second date is the same of the first date', function () { var dates = [new Date('2022-01-01'), new Date('2022-01-01')]; expect(compareTime(dates)).toBe(true); }); it('should return false when the second date is before the first date', function () { var dates = [new Date('2022-01-02'), new Date('2022-01-01')]; expect(compareTime(dates)).toBe(false); }); it('should return false when the input is invalid', function () { var dates = null; expect(compareTime(dates)).toBe(false); }); it('should return false when the input contains more or less than 2 dates', function () { var dates = [new Date('2022-01-01')]; expect(compareTime(dates)).toBe(false); }); });