import { describe, expect, it } from 'vitest' import { getEventScheduleConstraints } from '@/components/events/schedule/eventScheduleConstraints' const localIso = (year: number, month: number, day: number) => new Date(year, month, day).toISOString() describe('getEventScheduleConstraints', () => { it('uses the next minute for a start today and start + 1 for a same-day end', () => { const today = localIso(2026, 7, 11) const result = getEventScheduleConstraints({ now: new Date(2026, 7, 11, 10, 30), startDate: today, startTime: 12 * 60, endDate: today, }) expect(result.startMinimumTime).toBe(10 * 60 + 31) expect(result.endMinimumTime).toBe(12 * 60 + 1) }) it('does not constrain a future start or an end on a later day', () => { const result = getEventScheduleConstraints({ now: new Date(2026, 7, 11, 10, 30), startDate: localIso(2026, 7, 12), startTime: 12 * 60, endDate: localIso(2026, 7, 13), }) expect(result.startMinimumTime).toBe(0) expect(result.endMinimumTime).toBe(0) }) it('caps the next-minute boundary at the end of the day', () => { const today = localIso(2026, 7, 11) const result = getEventScheduleConstraints({ now: new Date(2026, 7, 11, 23, 59), startDate: today, endDate: today, }) expect(result.startMinimumTime).toBe(1440) expect(result.endMinimumTime).toBe(1) }) it('ignores invalid or missing date values', () => { const result = getEventScheduleConstraints({ now: new Date(2026, 7, 11, 10, 30), startDate: 'invalid', endDate: undefined, }) expect(result.startMinimumTime).toBe(0) expect(result.endMinimumTime).toBe(0) }) })