import { createElement } from "react"; import { renderToStaticMarkup } from "react-dom/server"; import { describe, expect, it } from "vitest"; import { DefeatedPrompt, DungeonCompletePrompt } from "./Hud"; import { ResurrectionDestination } from "./ResurrectionDestination"; describe("defeated prompt", () => { it("offers an explicit dungeon respawn while explaining that waiting is allowed", () => { const markup = renderToStaticMarkup(createElement(DefeatedPrompt, { gameMode: "dungeon", resurrectionCharges: 0, onReturn: () => undefined, })); expect(markup).toContain("wait for a party member to resurrect you"); expect(markup).toContain("Respawn at entrance"); expect(markup).toContain("Respawning resets the current encounter and restores the party."); }); it("explains player-only resurrection and optional Recall during an ongoing party fight", () => { const markup = renderToStaticMarkup(createElement(DefeatedPrompt, { gameMode: "dungeon", resurrectionCharges: 0, partyStillFighting: true, onReturn: () => undefined, })); expect(markup).toContain("Your party will keep fighting where they are."); expect(markup).toContain("Use Recall if you want to regroup."); expect(markup).toContain("Respawn at entrance"); expect(markup).not.toContain("resets the current encounter"); }); it("does not offer a Manastorm resurrection when no shared charges remain", () => { const markup = renderToStaticMarkup(createElement(DefeatedPrompt, { gameMode: "manastorm", resurrectionCharges: 0, onReturn: () => undefined, })); expect(markup).toContain("No shared resurrection charges remain"); expect(markup).not.toContain("Resurrect now"); }); it("offers labeled entrance and killed-boss choices on the player defeat prompt", () => { const markup = renderToStaticMarkup(createElement(DefeatedPrompt, { gameMode: "dungeon", resurrectionCharges: 0, onReturn: () => undefined, checkpoints: [ { id: "entrance", name: "Dungeon entrance", spawn: { footPosition: [0, 0, 0], yaw: 0 } }, { id: "boss:bazil", name: "Bazil Thredd", spawn: { footPosition: [20, 0, 0], yaw: 0 } }, ], })); expect(markup).toContain("Resurrect at"); expect(markup).toContain("value=\"boss:bazil\""); expect(markup).toContain("Dungeon entrance"); }); it("retains a selected boss destination in the shared chooser", () => { const markup = renderToStaticMarkup(createElement(ResurrectionDestination, { checkpoints: [ { id: "entrance", name: "Dungeon entrance", spawn: { footPosition: [0, 0, 0], yaw: 0 } }, { id: "boss:bazil", name: "Bazil Thredd", spawn: { footPosition: [20, 0, 0], yaw: 0 } }, ], value: "boss:bazil", onChange: () => undefined, })); expect(markup).toContain("value=\"boss:bazil\" selected=\"\""); }); }); describe("dungeon completion prompt", () => { it("keeps final-room looting available while exposing an explicit run exit", () => { const markup = renderToStaticMarkup(createElement(DungeonCompletePrompt, { dungeonTitle: "The Deadmines", onFinish: () => undefined, })); expect(markup).toContain("The Deadmines complete"); expect(markup).toContain("Loot the room or finish the run"); expect(markup).toContain("Finish dungeon"); }); });