import { describe, it, expect } from "vitest";
import { parseHyperframes, isHyperframes } from "../hyperframes";
describe("parseHyperframes", () => {
it("parses a minimal hyperframes document", () => {
const html = `
Test
`;
const result = parseHyperframes(html);
expect(result.isHyperframes).toBe(true);
expect(result.frames).toHaveLength(1);
expect(result.frames[0].duration).toBe(3000);
expect(result.frames[0].innerHtml).toContain("Frame 1");
expect(result.title).toBe("Test");
});
it("preserves zero duration from data-duration attribute (issue #110)", () => {
const html = `
Zero Dur
`;
const result = parseHyperframes(html);
expect(result.isHyperframes).toBe(true);
expect(result.frames).toHaveLength(1);
expect(result.frames[0].duration).toBe(0);
});
it("preserves zero duration from inline comment marker fallback (issue #110)", () => {
const html = `
Marker Zero
`;
const result = parseHyperframes(html);
expect(result.isHyperframes).toBe(true);
expect(result.frames).toHaveLength(1);
expect(result.frames[0].duration).toBe(0);
});
it("falls back to default when data-duration is absent", () => {
const html = `
No Dur
`;
const result = parseHyperframes(html);
expect(result.isHyperframes).toBe(true);
expect(result.frames).toHaveLength(1);
expect(result.frames[0].duration).toBe(3000);
});
it("parses multiple frames with mixed durations including zero", () => {
const html = `
Mixed
`;
const result = parseHyperframes(html);
expect(result.frames).toHaveLength(3);
expect(result.frames[0].duration).toBe(0);
expect(result.frames[1].duration).toBe(1000);
expect(result.frames[2].duration).toBe(3000);
});
});
describe("isHyperframes", () => {
it("returns false for empty or non-hyperframes html", () => {
expect(isHyperframes("")).toBe(false);
expect(isHyperframes("hello
")).toBe(false);
});
it("returns true when at least one frame section exists", () => {
const html = ``;
expect(isHyperframes(html)).toBe(true);
});
});