feat : error when mulitple apply not supporting
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { applyTeamFields, limitPresets, parseTeamPresets } from "./team-tools";
|
||||
import {
|
||||
applyTeamFields,
|
||||
findUnsupportedTeamWeapon,
|
||||
limitPresets,
|
||||
parseTeamPresets,
|
||||
type TeamToolValue,
|
||||
} from "./team-tools";
|
||||
|
||||
const team = (id: string, title = id) => ({
|
||||
const team = (id: string, title = id): TeamToolValue => ({
|
||||
clientId: id, title, rotationSeconds: "20", combo: "E > Q",
|
||||
members: [1, 2, 3, 4].map((n) => ({ characterKey: `${id}-${n}`, weaponKey: null, artifactKey: null, secondArtifactKey: null, constellation: 0, refinement: 1, damage: String(n) })),
|
||||
});
|
||||
@@ -41,6 +47,24 @@ describe("team bulk tools", () => {
|
||||
expect(result[1].members.slice(1)).toEqual(target.members.slice(1));
|
||||
});
|
||||
|
||||
it("detects an unsupported character and weapon after bulk apply", () => {
|
||||
const target = team("target");
|
||||
target.members[0] = {
|
||||
...target.members[0],
|
||||
characterKey: "varka",
|
||||
weaponKey: "wolf-fang",
|
||||
};
|
||||
|
||||
expect(
|
||||
findUnsupportedTeamWeapon(
|
||||
[target],
|
||||
new Set(["target"]),
|
||||
[{ key: "varka", name: "Varka", weaponType: "WEAPON_CLAYMORE" }],
|
||||
[{ key: "wolf-fang", name: "Wolf-Fang", weaponType: "WEAPON_SWORD_ONE_HAND" }],
|
||||
),
|
||||
).toEqual({ characterName: "Varka", weaponName: "Wolf-Fang" });
|
||||
});
|
||||
|
||||
it("deduplicates and limits presets", () => {
|
||||
const presets = Array.from({ length: 7 }, (_, index) => ({ id: String(index), name: String(index), createdAt: String(index), team: { ...team(String(index)), clientId: undefined as never } }));
|
||||
expect(limitPresets([presets[0], presets[0], ...presets.slice(1)])).toHaveLength(5);
|
||||
|
||||
Reference in New Issue
Block a user