calendar due date
Gitea Actions Demo / Deploy (push) Successful in 31s

This commit is contained in:
vadim committed 2026-10-12 11:08:27 +03:00
1 parent cb29c7d2c4
commit 7aecc6f96e
32 files changed
+532 -25

No files matched your search

@@ -0,0 +1,37 @@
import { describe, expect, it } from 'vitest';
import { CalendarRange } from './calendar-range.vo.js';
import { InvalidCalendarRangeException } from '../exceptions/invalid-calendar-range.exception.js';
describe('CalendarRange', () => {
it('accepts a 6-week month grid', () => {
const from = new Date('2026-09-28T00:00:00+03:00');
const to = new Date('2026-11-09T00:00:00+03:00');
const range = CalendarRange.create({ from, to });
expect(range.from).toBe(from);
expect(range.to).toBe(to);
});
it('rejects an invalid date', () => {
expect(() => CalendarRange.create({ from: new Date('nope'), to: new Date() })).toThrow(
InvalidCalendarRangeException,
);
});
it('rejects from equal to or after to', () => {
const date = new Date('2026-10-01T00:00:00Z');
expect(() => CalendarRange.create({ from: date, to: date })).toThrow(InvalidCalendarRangeException);
expect(() => CalendarRange.create({ from: new Date('2026-10-02T00:00:00Z'), to: date })).toThrow(
InvalidCalendarRangeException,
);
});
it(`rejects a range longer than ${CalendarRange.MAX_DAYS} days`, () => {
const from = new Date('2026-10-01T00:00:00Z');
const to = new Date(from.getTime() + (CalendarRange.MAX_DAYS * 24 * 60 * 60 * 1000 + 1));
expect(() => CalendarRange.create({ from, to })).toThrow(InvalidCalendarRangeException);
});
});