Files
healer-man/src/app/shellRuntimeDelegation.test.ts
T
2026-09-12 11:07:25 -04:00

67 lines
2.6 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
import { registerDungeonShellRuntime } from "./dungeonShellRuntimeBridge";
import { registerManastormShellRuntime } from "./manastormShellRuntimeBridge";
import { useShellStore } from "./shellStore";
import { SHELVED_MODES_ENABLED } from "./releaseFeatures";
const normalReleaseIt = SHELVED_MODES_ENABLED ? it.skip : it;
const shelvedModeIt = SHELVED_MODES_ENABLED ? it : it.skip;
describe("on-demand shell runtime delegation", () => {
it("delegates dungeon entry after its phase runtime is installed", () => {
const enterDungeon = vi.fn(() => true);
registerDungeonShellRuntime({ enterDungeon });
expect(useShellStore.getState().enterDungeon("wailing-caverns", "healer")).toBe(true);
expect(enterDungeon).toHaveBeenCalledWith("wailing-caverns", "healer");
});
normalReleaseIt("ignores registered Manastorm delegates in a normal release", () => {
const enterManastorm = vi.fn(() => true);
const saveSelectedLoadout = vi.fn(() => true);
const abandonRun = vi.fn();
const failRun = vi.fn();
registerManastormShellRuntime({
enterManastorm,
saveSelectedLoadout,
abandonRun,
failRun,
leaveActiveGame: vi.fn(),
});
expect(useShellStore.getState().enterManastorm("healer", 3, 6)).toBe(false);
expect(useShellStore.getState().saveSelectedManastormLoadout(["spell-1"])).toBe(false);
useShellStore.getState().abandonManastormRun();
useShellStore.getState().failActiveManastorm();
expect(enterManastorm).not.toHaveBeenCalled();
expect(saveSelectedLoadout).not.toHaveBeenCalled();
expect(abandonRun).not.toHaveBeenCalled();
expect(failRun).not.toHaveBeenCalled();
});
shelvedModeIt("delegates Manastorm operations after its phase runtime is installed", () => {
const enterManastorm = vi.fn(() => true);
const saveSelectedLoadout = vi.fn(() => true);
const abandonRun = vi.fn();
const failRun = vi.fn();
const leaveActiveGame = vi.fn();
registerManastormShellRuntime({
enterManastorm,
saveSelectedLoadout,
abandonRun,
failRun,
leaveActiveGame,
});
expect(useShellStore.getState().enterManastorm("healer", 3, 6)).toBe(true);
expect(useShellStore.getState().saveSelectedManastormLoadout(["spell-1"])).toBe(true);
useShellStore.getState().abandonManastormRun();
useShellStore.getState().failActiveManastorm();
expect(enterManastorm).toHaveBeenCalledWith("healer", 3, 6);
expect(saveSelectedLoadout).toHaveBeenCalledWith(["spell-1"]);
expect(abandonRun).toHaveBeenCalledOnce();
expect(failRun).toHaveBeenCalledOnce();
});
});