-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Expand file tree
/
Copy pathgame.test.ts
More file actions
43 lines (38 loc) · 1.23 KB
/
game.test.ts
File metadata and controls
43 lines (38 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { expect, test } from "bun:test";
import { AdventureGame, playScriptedAdventure } from "./game";
test("the local game engine exposes deterministic actions", () => {
const game = new AdventureGame();
expect(game.getCurrentRoom().id).toBe("entrance");
expect(game.getAvailableActions()).toContain("take rusty torch");
const blocked = game.executeAction("go north");
expect(blocked).toContain("Torch-lit Hallway");
expect(game.getAvailableActions()).toContain("attack");
expect(game.executeAction("go north")).toContain("blocks your path");
});
test("a scripted no-LLM run can complete the dungeon", () => {
const finalState = playScriptedAdventure([
"take rusty torch",
"go north",
"attack",
"attack",
"go east",
"take ancient sword",
"take health potion",
"go west",
"go north",
"attack with sword",
"attack with sword",
"go west",
"take golden key",
"go east",
"go north",
"attack with sword",
"attack with sword",
"use health potion",
"attack with sword",
]);
expect(finalState.gameOver).toBe(true);
expect(finalState.victory).toBe(true);
expect(finalState.score).toBeGreaterThanOrEqual(350);
expect(finalState.health).toBeGreaterThan(0);
});