import { describe, it, expect } from "vitest"; import { shotThumbnail, isGeneratedThumbnail } from "./shot-thumbnail"; /** * The whole point of the second column is that promotion can never destroy the * reference frame that came with the brief. These cases are that guarantee. */ describe("shotThumbnail", () => { it("prefers the reference frame over a render-derived one", () => { expect( shotThumbnail({ thumbnailUrl: "/api/files/image/ref.jpg", generatedThumbnailUrl: "/api/files/image/gen.jpg" }) ).toBe("/api/files/image/ref.jpg"); }); it("falls back to the render frame when the show supplied no still", () => { expect(shotThumbnail({ thumbnailUrl: null, generatedThumbnailUrl: "/api/files/image/gen.jpg" })).toBe( "/api/files/image/gen.jpg" ); }); it("returns null when the shot has neither", () => { expect(shotThumbnail({ thumbnailUrl: null, generatedThumbnailUrl: null })).toBeNull(); expect(shotThumbnail(null)).toBeNull(); expect(shotThumbnail({})).toBeNull(); }); it("treats an empty string as no thumbnail", () => { // updateShot accepts "" from a cleared form field, which must not win over // a generated frame or render as a broken . expect(shotThumbnail({ thumbnailUrl: "", generatedThumbnailUrl: "/api/files/image/gen.jpg" })).toBe( "/api/files/image/gen.jpg" ); }); it("reports whether what is displayed came from a render", () => { expect(isGeneratedThumbnail({ thumbnailUrl: null, generatedThumbnailUrl: "/g.jpg" })).toBe(true); expect(isGeneratedThumbnail({ thumbnailUrl: "/r.jpg", generatedThumbnailUrl: "/g.jpg" })).toBe(false); expect(isGeneratedThumbnail({ thumbnailUrl: null, generatedThumbnailUrl: null })).toBe(false); }); });