51 lines
2.9 KiB
TypeScript
51 lines
2.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { generateTeam } from "./translator/generate";
|
|
import type { Catalog, CatalogItem } from "./translator/types";
|
|
import { importGuideTeam, type TeamGuideTeam } from "./team-guides";
|
|
|
|
const item = (id: string, key: string, name: string, weaponType?: string): CatalogItem => ({ id, key, name, imageUrl: "", rarity: 5, weaponType, supported: true, baseStats: [] });
|
|
const catalog: Catalog = {
|
|
version: "test",
|
|
characters: [item("char-1", "mavuika", "Mavuika", "claymore"), item("char-2", "xilonen", "Xilonen", "sword")],
|
|
weapons: [item("weapon-1", "favoniusgreatsword", "Favonius Greatsword", "claymore"), item("weapon-2", "favoniussword", "Favonius Sword", "sword")],
|
|
artifacts: [item("set-1", "obsidiancodex", "Obsidian Codex"), item("set-2", "scrolloftheheroofcindercity", "Scroll")],
|
|
};
|
|
|
|
const guideTeam = (combo = "Mavuika E > Xilonen E N2"): TeamGuideTeam => ({
|
|
id: "team-1",
|
|
title: "Guide team",
|
|
conditionName: "Main Sheet",
|
|
combo,
|
|
members: [
|
|
{ position: 0, characterId: "char-1", weaponId: "weapon-1", artifactOneId: "set-1", artifactTwoId: null, constellation: 2, refinement: 1 },
|
|
{ position: 1, characterId: "char-2", weaponId: "weapon-2", artifactOneId: "set-1", artifactTwoId: "set-2", constellation: 0, refinement: 5 },
|
|
],
|
|
});
|
|
|
|
describe("team guide import", () => {
|
|
it("maps guide loadouts and defaults into a generated team", () => {
|
|
const result = importGuideTeam(guideTeam(), catalog);
|
|
expect(result.error).toBeUndefined();
|
|
expect(result.team!.builds[0]).toMatchObject({ characterKey: "mavuika", weaponKey: "favoniusgreatsword", constellation: 2, refinement: 1, artifactMode: "4pc", artifactOneKey: "obsidiancodex", level: 90, talents: [9, 9, 9], sands: "atk%", goblet: "atk%", circlet: "cr" });
|
|
expect(result.team!.builds[1]).toMatchObject({ artifactMode: "2+2", artifactOneKey: "obsidiancodex", artifactTwoKey: "scrolloftheheroofcindercity", refinement: 5 });
|
|
expect(result.team!.rotation).toMatchObject({ enabled: true, text: "Mavuika E > Xilonen E N2", repeat: false });
|
|
expect(generateTeam(result.team!)).toContain('xilonen add set="scrolloftheheroofcindercity" count=2;');
|
|
});
|
|
|
|
it("preserves unsupported combo text with rotation disabled", () => {
|
|
const result = importGuideTeam(guideTeam("Mavuika 3[C ED] Q"), catalog);
|
|
expect(result.team!.rotation).toEqual({ enabled: false, text: "Mavuika 3[C ED] Q", repeat: false });
|
|
expect(generateTeam(result.team!)).not.toContain("# Rotation");
|
|
});
|
|
|
|
it.each(["", " - "])("omits an empty guide combo %#", (combo) => {
|
|
expect(importGuideTeam(guideTeam(combo), catalog).team!.rotation).toBeUndefined();
|
|
});
|
|
|
|
it("reports missing catalog entries before importing", () => {
|
|
const source = guideTeam();
|
|
source.members[0].weaponId = "missing";
|
|
expect(importGuideTeam(source, catalog).error).toBe("Weapon missing is missing from the catalog.");
|
|
});
|
|
});
|