import { describe, expect, it } from "vitest"; import { checkCountdown, daysUntilNextFriday, } from "../src/game/world/day-timers"; describe("RTC day countdowns", () => { it("expires at the deadline, including across the 140-day wrap", () => { const start = { remaining: 3, day: 139 }; const next = checkCountdown(start, 140); expect(next).toEqual({ done: false, timer: { remaining: 2, day: 0 } }); expect(checkCountdown(next.timer, 140)).toEqual(next); expect(checkCountdown(next.timer, 142)).toEqual({ done: true, timer: { remaining: 0, day: 2 }, }); expect(checkCountdown(start, 150).done).toBe(true); expect(checkCountdown(undefined, 140).done).toBe(true); expect(start).toEqual({ remaining: 3, day: 139 }); }); it("keeps a Friday prize closed until the following Friday", () => { expect( Array.from({ length: 7 }, (_, day) => daysUntilNextFriday(day)), ).toEqual([5, 4, 3, 2, 1, 7, 6]); }); });