UNPKG

date-limits

Version:

Check if a date is before a flexible limit.

22 lines (21 loc) 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const is_date_before_limit_1 = require("./is-date-before-limit"); describe('isDateBeforeLimit', () => { const referenceDate = new Date('2024-11-22T20:00:00.000Z'); function idbl(year, month, day, config) { return (0, is_date_before_limit_1.isDateBeforeLimit)(date(year, month, day), config, referenceDate); } function date(year, month, day) { const yearStr = year.toString().padStart(4, '0'); const monthStr = month.toString().padStart(2, '0'); const dayStr = day.toString().padStart(2, '0'); return new Date(`${yearStr}-${monthStr}-${dayStr}T23:59:59.999Z`); } it('should return correct value for single date config', () => { expect(idbl(2024, 1, 1, { year: 2023, month: 10, day: 19 })).toBeFalse(); }); it('should return correct value for multiple date configs', () => { expect(idbl(2024, 1, 1, [{ year: 2023 }, { year: 2024, day: 29 }])).toBeTrue(); }); });