Skip to content

Commit f81fbb9

Browse files
committed
feat: add actionsEqual
Closes: #2
1 parent b850ba5 commit f81fbb9

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

src/testClient.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ export namespace TestClient {
9393
expect(currentMain.value).toStrictEqual(expectedObjects)
9494
}
9595

96+
export async function actionsEqual(testClient: TestClient, expectedObjects: QspListItem []) {
97+
const currentMain = await getNewValue(
98+
testClient.lastSelectedTime,
99+
testClient.client.actions.getActions
100+
)
101+
expect(currentMain.value).toStrictEqual(expectedObjects)
102+
}
103+
96104
export async function select(testClient: TestClient, action: string) {
97105
const actions = await getNewValue(
98106
testClient.lastSelectedTime,

tests/mocks/actions.qsps

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,13 @@
99
'You click on the third action'
1010
end
1111
-
12+
13+
# startEmptyActions
14+
act 'start':
15+
gt 'emptyActions'
16+
end
17+
-
18+
19+
# emptyActions
20+
'Location with empty actions'
21+
-

tests/testClient.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,26 @@ describe("Action select", () => {
2121
})
2222
})
2323

24+
describe("Actions equals", () => {
25+
it("empty", async () => {
26+
const testClient = await TestClient.start("tests/mocks", "actions.qsps", StartingLocation.mkCustom("startEmptyActions"))
27+
// fix(actionsEqual): the function does not respond if you run the game without actions
28+
await TestClient.actionsEqual(testClient, [
29+
{ name: "start", image: ""},
30+
])
31+
await TestClient.select(testClient, "start")
32+
await TestClient.actionsEqual(testClient, [])
33+
})
34+
it("Three actions", async () => {
35+
const testClient = await TestClient.start("tests/mocks", "actions.qsps")
36+
await TestClient.actionsEqual(testClient, [
37+
{ name: "First action", image: ""},
38+
{ name: "Second action", image: ""},
39+
{ name: "Third action", image: ""},
40+
])
41+
})
42+
})
43+
2444
test("IncLib", async () => {
2545
const testClient = await TestClient.start("tests/mocks", "game.qsps")
2646
await TestClient.select(testClient, "start")

0 commit comments

Comments
 (0)