Files
buzz-sheet/lib/catalog/lunaris.test.ts
T
gunshiz 22b09a6136
CI / Verify (push) Successful in 1m7s
CI / Build immutable images and deploy (push) Successful in 3m7s
feat(guides): add team loadouts and element icons
2026-08-30 05:39:54 +00:00

62 lines
1.9 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
avatarIconName,
characterDetailSchema,
cleanLunarisText,
constellationSnapshot,
supportsWeaponType,
} from "@/lib/catalog/lunaris";
describe("Lunaris character data", () => {
it("maps CardImg names to the avatar icon endpoint", () => {
expect(avatarIconName("UI_Gacha_AvatarIcon_Ineffa")).toBe(
"UI_AvatarIcon_Ineffa",
);
});
it("removes display markup from constellation text", () => {
expect(cleanLunarisText('"A {LINK#N1}<color=#fff>bright</color>{/LINK} morning"')).toBe("A bright morning");
});
it("normalizes constellation levels and icon keys", () => {
const result = constellationSnapshot({
constellations: {
const1: { name: '"First"', description: "Detail", icon: "UI_Talent_Test_01" },
},
}, (icon) => `catalog/1/constellations/${icon}.webp`);
expect(result).toEqual([{
level: 1,
name: "First",
description: "Detail",
iconKey: "catalog/1/constellations/UI_Talent_Test_01.webp",
}]);
});
it("accepts characters that do not have constellations", () => {
const detail = characterDetailSchema.parse({ constellations: null });
expect(constellationSnapshot(detail, (icon) => icon)).toEqual([]);
});
it("reads the supported weapon type from character details", () => {
const detail = characterDetailSchema.parse({
info: { element: "Cryo", weapon: "WEAPON_SWORD_ONE_HAND" },
constellations: null,
});
expect(detail.info?.weapon).toBe("WEAPON_SWORD_ONE_HAND");
expect(detail.info?.element).toBe("Cryo");
});
it("matches only weapons supported by the character", () => {
expect(
supportsWeaponType("WEAPON_SWORD_ONE_HAND", "WEAPON_SWORD_ONE_HAND"),
).toBe(true);
expect(
supportsWeaponType("WEAPON_SWORD_ONE_HAND", "WEAPON_CATALYST"),
).toBe(false);
expect(supportsWeaponType(undefined, "WEAPON_SWORD_ONE_HAND")).toBe(false);
});
});