forked from phenom/healer-man
29 lines
1.8 KiB
TypeScript
29 lines
1.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { CharacterProfile } from "../app/types";
|
|
import { preloadAbilityCatalogsForClasses } from "./abilityCatalog";
|
|
import { createArenaCharacterKit } from "./arenaCharacter";
|
|
import { controlledArenaActor } from "./arenaPlayer";
|
|
import type { ArenaAuthoritativeSnapshot } from "./arenaTypes";
|
|
|
|
describe("arena character selection and saved actions", () => {
|
|
it("keeps selected character bindings and enough mana to use learned spells", async () => {
|
|
await preloadAbilityCatalogsForClasses(["priest"]);
|
|
const character = { id: "mine", name: "My Priest", classId: "priest", raceId: "human", level: 80,
|
|
equipment: {}, inventory: [], talentRanks: {}, actionBindings: { "primary:face-left": "priest-flash-heal", "primary:r1": null } } as unknown as CharacterProfile;
|
|
const kit = createArenaCharacterKit(character);
|
|
expect(kit.actionBindings["primary:face-left"]).toBe("priest-flash-heal");
|
|
expect(kit.actionBindings["primary:r1"]).toBeNull();
|
|
expect(kit.resource.maximum).toBeGreaterThan(kit.abilities["priest-flash-heal"].cost.amount);
|
|
expect(kit.abilities.heal).toBeUndefined();
|
|
expect(kit.stats?.health).toBeGreaterThan(0);
|
|
});
|
|
|
|
it("uses server control ownership instead of selecting an arbitrary friendly bot", () => {
|
|
const actors = [{ id: "bot", team: 0, isBot: true }, { id: "mine", team: 1, isBot: false, characterId: "saved" }];
|
|
const snapshot = { mode: "ranked-pvp", controlledActorId: "mine", actors } as unknown as ArenaAuthoritativeSnapshot;
|
|
expect(controlledArenaActor(snapshot, { id: "saved" })?.id).toBe("mine");
|
|
expect(controlledArenaActor({ ...snapshot, controlledActorId: undefined }, { id: "saved" })?.id).toBe("mine");
|
|
expect(controlledArenaActor({ ...snapshot, controlledActorId: undefined }, { id: "missing" })).toBeNull();
|
|
});
|
|
});
|