import { describe, expect, it } from "vitest"; import { COPY, LANGS, VIDEO_IDS, translate } from "./videos"; const MAX_LINES = 2; /** Longer lines get too small to read on a phone. */ const MAX_LINE_LENGTH = 24; describe("video copy", () => { it.each(VIDEO_IDS)("%s has the same slides in every language", (id) => { const [first, ...others] = LANGS.map((lang) => Object.keys(COPY[id][lang].slides).sort()); for (const slides of others) expect(slides).toEqual(first); }); it.each(VIDEO_IDS)("%s keeps every headline to two short lines", (id) => { for (const lang of LANGS) { for (const [slide, lines] of Object.entries(COPY[id][lang].slides)) { expect(lines.length, `${id} ${lang} ${slide}`).toBeGreaterThan(0); expect(lines.length, `${id} ${lang} ${slide}`).toBeLessThanOrEqual(MAX_LINES); for (const line of lines) { expect(line.length, `${id} ${lang} ${slide}: "${line}"`).toBeLessThanOrEqual(MAX_LINE_LENGTH); } } } }); it.each(VIDEO_IDS)("%s ends with a call to action slide", (id) => { for (const lang of LANGS) expect(COPY[id][lang].slides).toHaveProperty("cta"); }); it.each(VIDEO_IDS)("%s has a post that names the website and never an email address", (id) => { for (const lang of LANGS) { const { post } = COPY[id][lang]; expect(post).toContain("www.mintel.me"); expect(post).not.toContain("@"); } }); }); describe("translate", () => { it("leaves English labels as they are", () => { expect(translate("en", "Invoice")).toBe("Invoice"); }); it("returns the German label when there is one", () => { expect(translate("de", "Invoice")).toBe("Rechnung"); }); it("falls back to the given text when there is no German label", () => { expect(translate("de", "Shop")).toBe("Shop"); }); });