Release Healer Man 0.1.22
This commit is contained in:
1 parent
f6f2375145
commit
7f6001723a
144 files changed
+54107
-690
No files matched your search
@@ -0,0 +1,78 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type { OnlineGroupActivity } from "./onlineGroupTypes";
|
||||
import { enterOnlineGroupActivity } from "./OnlineGroupCoordinator";
|
||||
|
||||
const DUNGEON_ACTIVITY: OnlineGroupActivity = {
|
||||
id: "activity-dungeon-1",
|
||||
type: "dungeon",
|
||||
contentId: "deadmines",
|
||||
fillWithAi: true,
|
||||
partySize: 5,
|
||||
startingLevel: null,
|
||||
startedAt: 1,
|
||||
};
|
||||
|
||||
function entryDependencies(enterDungeon: () => boolean) {
|
||||
return {
|
||||
installDungeonRuntime: vi.fn(async () => undefined),
|
||||
enterDungeon: vi.fn(enterDungeon),
|
||||
installManastormRuntime: vi.fn(async () => undefined),
|
||||
enterManastorm: vi.fn(() => true),
|
||||
};
|
||||
}
|
||||
|
||||
describe("online group activity entry", () => {
|
||||
it("leaves a dungeon activity unconsumed when dungeon entry fails", async () => {
|
||||
const consumeActivity = vi.fn();
|
||||
const dependencies = entryDependencies(() => false);
|
||||
|
||||
await expect(enterOnlineGroupActivity(
|
||||
DUNGEON_ACTIVITY,
|
||||
"healer",
|
||||
consumeActivity,
|
||||
dependencies,
|
||||
)).resolves.toBe(false);
|
||||
|
||||
expect(dependencies.installDungeonRuntime).toHaveBeenCalledOnce();
|
||||
expect(dependencies.enterDungeon).toHaveBeenCalledWith("deadmines", "healer");
|
||||
expect(consumeActivity).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("can retry the same dungeon activity and consumes it only after entry succeeds", async () => {
|
||||
const consumeActivity = vi.fn();
|
||||
const enterDungeon = vi.fn()
|
||||
.mockReturnValueOnce(false)
|
||||
.mockReturnValueOnce(true);
|
||||
const dependencies = entryDependencies(enterDungeon);
|
||||
|
||||
await enterOnlineGroupActivity(DUNGEON_ACTIVITY, "tank", consumeActivity, dependencies);
|
||||
expect(consumeActivity).not.toHaveBeenCalled();
|
||||
|
||||
await expect(enterOnlineGroupActivity(
|
||||
DUNGEON_ACTIVITY,
|
||||
"tank",
|
||||
consumeActivity,
|
||||
dependencies,
|
||||
)).resolves.toBe(true);
|
||||
|
||||
expect(dependencies.enterDungeon).toHaveBeenCalledTimes(2);
|
||||
expect(consumeActivity).toHaveBeenCalledOnce();
|
||||
expect(consumeActivity).toHaveBeenCalledWith(DUNGEON_ACTIVITY.id);
|
||||
});
|
||||
|
||||
it("does not consume the activity when loading the dungeon runtime throws", async () => {
|
||||
const consumeActivity = vi.fn();
|
||||
const dependencies = entryDependencies(() => true);
|
||||
dependencies.installDungeonRuntime.mockRejectedValueOnce(new Error("runtime unavailable"));
|
||||
|
||||
await expect(enterOnlineGroupActivity(
|
||||
DUNGEON_ACTIVITY,
|
||||
"damage",
|
||||
consumeActivity,
|
||||
dependencies,
|
||||
)).rejects.toThrow("runtime unavailable");
|
||||
|
||||
expect(dependencies.enterDungeon).not.toHaveBeenCalled();
|
||||
expect(consumeActivity).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user