feat : add image generator
This commit is contained in:
@@ -2,8 +2,13 @@ import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
accentGradient,
|
||||
detectThemeColorsFromPixels,
|
||||
elementGlowColor,
|
||||
elementGradientColors,
|
||||
elementOrder,
|
||||
normalizeHex,
|
||||
overviewFileName,
|
||||
overviewBlendModes,
|
||||
weaponTypeIconPath,
|
||||
} from "@/lib/overview-image";
|
||||
|
||||
@@ -42,10 +47,37 @@ describe("overview image generator", () => {
|
||||
expect(weaponTypeIconPath(null)).toBeNull();
|
||||
});
|
||||
|
||||
it("maps every element to gradient and fixed glow colors", () => {
|
||||
for (const element of elementOrder) {
|
||||
const [start, end] = elementGradientColors(element);
|
||||
expect(normalizeHex(start)).toBe(start);
|
||||
expect(normalizeHex(end)).toBe(end);
|
||||
expect(normalizeHex(elementGlowColor(element))).toBe(
|
||||
elementGlowColor(element),
|
||||
);
|
||||
}
|
||||
expect(elementGradientColors("Unknown")).toEqual(["#FFFFFF", "#FFFFFF"]);
|
||||
expect(elementGlowColor(null)).toBe("#FFFFFF");
|
||||
});
|
||||
|
||||
it("creates a safe PNG filename", () => {
|
||||
expect(overviewFileName("Traveler / Pyro", "Main DPS")).toBe(
|
||||
"overview-Traveler-Pyro-main-dps.png",
|
||||
);
|
||||
});
|
||||
|
||||
it("supports every Tailwind blend mode and detects top and bottom themes", () => {
|
||||
expect(overviewBlendModes.map((mode) => mode.value)).toHaveLength(18);
|
||||
const pixels = new Uint8ClampedArray([
|
||||
255, 0, 0, 255, 255, 0, 0, 255,
|
||||
255, 255, 0, 255, 255, 255, 0, 255,
|
||||
0, 0, 255, 255, 0, 0, 255, 255,
|
||||
0, 255, 255, 255, 0, 255, 255, 255,
|
||||
]);
|
||||
expect(detectThemeColorsFromPixels(pixels, 2, 4)).toEqual({
|
||||
top: ["#FF0000", "#FFFF00"],
|
||||
bottom: ["#0000FF", "#00FFFF"],
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user