import { describe, expect, it } from "vitest"; import { detectBlankSpans } from "./blankSpan.js"; import type { CraftFrame } from "./checkTypes.js"; const STEP = 0.125; /** An 8 fps grid over `duration` s, painted wherever `painted(t)` says. */ function frames(duration: number, painted: (time: number) => boolean): CraftFrame[] { const times = Array.from({ length: Math.round(duration / STEP) }, (_, index) => index * STEP); return times.map((time) => frame(time, painted(time))); } function frame(time: number, painted: boolean): CraftFrame { return { time, parts: [], held: false, painted, presence: painted ? 1 : 0, signature: "" }; } const fullContent = async (time: number) => frame(time, true); const emptyStage = async () => true; describe("detectBlankSpans", () => { it("reports an unpainted stretch closed by content on both sides", async () => { const findings = await detectBlankSpans( frames(6, (t) => t < 2 || t >= 3), fullContent, emptyStage, ); expect(findings.map((finding) => finding.timeRange)).toEqual([[2, 2.875]]); }); it("never reports a stretch that opens the film, even when the probes see content around it", async () => { expect( await detectBlankSpans( frames(6, (t) => t >= 1), fullContent, emptyStage, ), ).toEqual([]); }); it("never reports a stretch that ends the film", async () => { expect( await detectBlankSpans( frames(6, (t) => t < 4), fullContent, emptyStage, ), ).toEqual([]); }); });