import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { NOTIFICATION_REFRESH_INTERVAL_MS, scheduleNotificationRefresh, } from '@/lib/notification-runtime'; describe('notification refresh scheduling', () => { beforeEach(() => { vi.useFakeTimers(); }); afterEach(() => { vi.useRealTimers(); }); it('refreshes notifications periodically until cleanup', async () => { const refresh = vi.fn(); const cleanup = scheduleNotificationRefresh(refresh); await vi.advanceTimersByTimeAsync(NOTIFICATION_REFRESH_INTERVAL_MS); expect(refresh).toHaveBeenCalledTimes(1); cleanup(); await vi.advanceTimersByTimeAsync(NOTIFICATION_REFRESH_INTERVAL_MS); expect(refresh).toHaveBeenCalledTimes(1); }); });