import { describe, expect, it } from "vitest"; import { tickets } from "./latest"; describe("tickets", () => { it("treats the only ticket taken as the newest", () => { const t = tickets(); const a = t.take(); expect(t.isLatest(a)).toBe(true); }); it("treats an older ticket as out of date once a newer one is taken", () => { const t = tickets(); const older = t.take(); const newer = t.take(); expect(t.isLatest(older)).toBe(false); expect(t.isLatest(newer)).toBe(true); }); it("keeps an older ticket out of date after more tickets are taken", () => { const t = tickets(); const first = t.take(); t.take(); const last = t.take(); expect(t.isLatest(first)).toBe(false); expect(t.isLatest(last)).toBe(true); }); it("keeps separate sets of tickets apart", () => { const a = tickets(); const b = tickets(); const fromA = a.take(); b.take(); b.take(); expect(a.isLatest(fromA)).toBe(true); }); });