import { describe, it, expect } from "vitest"; import { clientShotCode, clientTaskTitle } from "./shot-code"; describe("clientShotCode", () => { it("prefers the client's alias", () => { expect(clientShotCode({ shotCode: "UNG_106_010_020", clientCode: "EP6_VFX_012" })).toBe("EP6_VFX_012"); }); it("falls back to our code when there is no alias", () => { expect(clientShotCode({ shotCode: "UNG_106_010_020", clientCode: null })).toBe("UNG_106_010_020"); expect(clientShotCode({ shotCode: "UNG_106_010_020" })).toBe("UNG_106_010_020"); }); it("ignores a whitespace-only alias", () => { expect(clientShotCode({ shotCode: "UNG_106_010_020", clientCode: " " })).toBe("UNG_106_010_020"); }); }); describe("clientTaskTitle", () => { const shot = { shotCode: "UNG_106_010_020", clientCode: "EP6_VFX_012" }; it("swaps the internal code out of a house-convention title", () => { expect(clientTaskTitle("UNG_106_010_020_cmp_TT_v004", shot)).toBe("EP6_VFX_012_cmp_TT_v004"); }); it("leaves the title alone when there is no alias", () => { const t = "UNG_106_010_020_cmp_TT_v004"; expect(clientTaskTitle(t, { shotCode: "UNG_106_010_020", clientCode: null })).toBe(t); }); it("leaves a title that does not carry the code untouched", () => { // Hand-edited titles are not guessed at — better an unhelpful title than a // mangled one. expect(clientTaskTitle("Roto pass", shot)).toBe("Roto pass"); }); it("swaps every occurrence", () => { expect(clientTaskTitle("UNG_106_010_020 / UNG_106_010_020_cmp", shot)).toBe("EP6_VFX_012 / EP6_VFX_012_cmp"); }); it("is a no-op when the alias equals the code", () => { const same = { shotCode: "UNG_106_010_020", clientCode: "UNG_106_010_020" }; expect(clientTaskTitle("UNG_106_010_020_cmp", same)).toBe("UNG_106_010_020_cmp"); }); });