import { describe, it, expect } from "vitest"; import { channelDetailPollMs } from "./channelDetailPoll"; import { type ChannelDetail } from "./api"; // Only deep_requested + backfill_done drive the decision; cast a partial for the pure predicate. const d = (over: Partial): ChannelDetail => over as ChannelDetail; describe("channelDetailPollMs", () => { it("polls at 4s while THIS user's full-history backfill is running", () => { expect(channelDetailPollMs(d({ deep_requested: true, backfill_done: false }))).toBe(4000); }); it("stops (false) once the back-catalogue is fully in", () => { expect(channelDetailPollMs(d({ deep_requested: true, backfill_done: true }))).toBe(false); }); it("stops (false) when the user hasn't requested full history", () => { expect(channelDetailPollMs(d({ deep_requested: false, backfill_done: false }))).toBe(false); }); it("stops (false) before the detail has loaded", () => { expect(channelDetailPollMs(undefined)).toBe(false); }); });