import { afterEach, describe, expect, it, vi } from "vitest"; import { prepareBossTesting } from "./bossTestingRuntime"; import { BOSS_TESTING_CATALOG } from "../game/bossTesting"; import * as content from "../content/contentManager"; afterEach(() => vi.restoreAllMocks()); describe("boss asset preparation", () => { const boss = BOSS_TESTING_CATALOG[0]; it("automatically downloads and verifies only the selected boss's dungeon pack", async () => { const usable = vi.spyOn(content, "dungeonContentIsUsable").mockReturnValueOnce(false).mockReturnValueOnce(false).mockReturnValue(true); vi.spyOn(content, "initializeContentSystem").mockResolvedValue(); const install = vi.spyOn(content, "installContentPack").mockResolvedValue(); await prepareBossTesting(boss); expect(install).toHaveBeenCalledExactlyOnceWith(`dungeon:${boss.dungeonId}`); expect(usable).toHaveBeenCalledWith(boss.dungeonId); }); it("reuses installed content and stops entry after failed verification", async () => { const usable = vi.spyOn(content, "dungeonContentIsUsable").mockReturnValue(true); vi.spyOn(content, "initializeContentSystem").mockResolvedValue(); const install = vi.spyOn(content, "installContentPack").mockResolvedValue(); await prepareBossTesting(boss); expect(install).not.toHaveBeenCalled(); usable.mockReturnValue(false); await expect(prepareBossTesting(boss)).rejects.toThrow(/verified/); }); });