Files
i-want-to-heal-mmo/src/frontend/classHelpStore.test.ts
T

43 lines
1.4 KiB
TypeScript

import { afterEach, describe, expect, it } from "vitest";
import { getFrontendSnapshot, useFrontendStore } from "./store";
const originalState = useFrontendStore.getState();
afterEach(() => {
useFrontendStore.setState({
activeSlotId: originalState.activeSlotId,
screen: originalState.screen,
guideClassId: originalState.guideClassId,
guideAbilityId: originalState.guideAbilityId,
notice: originalState.notice,
});
});
describe("Class Help frontend state", () => {
it("opens on ability one, resets selection on class change, and syncs guide state", () => {
useFrontendStore.setState({
activeSlotId: null,
screen: "home",
guideClassId: "shaman",
guideAbilityId: "ability6",
notice: "Old notice",
});
useFrontendStore.getState().openClassHelp();
let state = useFrontendStore.getState();
expect(state.screen).toBe("class-help");
expect(state.guideClassId).toBe("shaman");
expect(state.guideAbilityId).toBe("ability1");
expect(state.notice).toBe("");
state.selectGuideClass("paladin");
state.selectGuideAbility("ability5");
const snapshot = getFrontendSnapshot();
expect(snapshot.guideClassId).toBe("paladin");
expect(snapshot.guideAbilityId).toBe("ability5");
expect("openClassHelp" in snapshot).toBe(false);
expect("selectGuideClass" in snapshot).toBe(false);
expect("selectGuideAbility" in snapshot).toBe(false);
});
});