52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
accentGradient,
|
|
normalizeHex,
|
|
overviewFileName,
|
|
weaponTypeIconPath,
|
|
} from "@/lib/overview-image";
|
|
|
|
describe("overview image generator", () => {
|
|
it("normalizes valid colors and rejects invalid colors", () => {
|
|
expect(normalizeHex(" #e9a51a ")).toBe("#E9A51A");
|
|
expect(normalizeHex("#fff")).toBeNull();
|
|
expect(normalizeHex("orange")).toBeNull();
|
|
});
|
|
|
|
it("creates a deterministic accent gradient", () => {
|
|
expect(accentGradient("#E9A51A")).toBe(
|
|
"linear-gradient(90deg, #CD9117 0%, #E9A51A 25%, #F1C56A 50%, #E9A51A 75%, #CD9117 100%)",
|
|
);
|
|
expect(accentGradient("#FF0000", "#0000FF")).toBe(
|
|
"linear-gradient(90deg, #E00000 0%, #FF0000 25%, #AC59AC 50%, #0000FF 75%, #0000E0 100%)",
|
|
);
|
|
});
|
|
|
|
it("maps every catalog weapon type to a PNG", () => {
|
|
expect(weaponTypeIconPath("WEAPON_SWORD_ONE_HAND")).toBe(
|
|
"/icon/weapon-types/sword.png",
|
|
);
|
|
expect(weaponTypeIconPath("WEAPON_CLAYMORE")).toBe(
|
|
"/icon/weapon-types/claymore.png",
|
|
);
|
|
expect(weaponTypeIconPath("WEAPON_POLE")).toBe(
|
|
"/icon/weapon-types/polearm.png",
|
|
);
|
|
expect(weaponTypeIconPath("WEAPON_BOW")).toBe(
|
|
"/icon/weapon-types/bow.png",
|
|
);
|
|
expect(weaponTypeIconPath("WEAPON_CATALYST")).toBe(
|
|
"/icon/weapon-types/catalyst.png",
|
|
);
|
|
expect(weaponTypeIconPath(null)).toBeNull();
|
|
});
|
|
|
|
it("creates a safe PNG filename", () => {
|
|
expect(overviewFileName("Traveler / Pyro", "Main DPS")).toBe(
|
|
"overview-Traveler-Pyro-main-dps.png",
|
|
);
|
|
});
|
|
|
|
});
|