import { describe, expect, it } from 'vitest'; import { msUntilNext } from './scheduler.js'; // msUntilNext works in local time (the container's TZ); the tests build // their expectations with local-time Dates, so they hold in any zone. describe('msUntilNext', () => { it('targets today when the time is still ahead', () => { const now = new Date(2026, 6, 11, 1, 30, 0); expect(msUntilNext(now, '03:00')).toBe(90 * 60 * 1000); }); it('targets tomorrow when the time has passed', () => { const now = new Date(2026, 6, 11, 3, 0, 1); expect(msUntilNext(now, '03:00')).toBe(24 * 60 * 60 * 1000 - 1000); }); it('an exact hit schedules a full day ahead (never a zero delay)', () => { const now = new Date(2026, 6, 11, 3, 0, 0); expect(msUntilNext(now, '03:00')).toBe(24 * 60 * 60 * 1000); }); });