import { describe, expect, it } from "vitest"; import type { TFunction } from "i18next"; import { isWithoutLength, withLeftOutCount } from "./withoutLength"; const t = ((key: string, o: { count: number }) => `${key}:${o.count}`) as unknown as TFunction; describe("a total and the videos it cannot hold", () => { it("counts every video the server sent no length for", () => { expect(isWithoutLength({ duration_seconds: null })).toBe(true); expect(isWithoutLength({ duration_seconds: 5400 })).toBe(false); expect(isWithoutLength({ duration_seconds: 0 })).toBe(false); }); it("names them beside the sum, or alone when nothing summed", () => { expect(withLeftOutCount("12 hr 5 min", 2, t)).toBe("12 hr 5 min card.withoutLength:2"); expect(withLeftOutCount("", 1, t)).toBe("card.withoutLength:1"); expect(withLeftOutCount("12 hr 5 min", 0, t)).toBe("12 hr 5 min"); }); });