Skip to content

Commit 1e53e16

Browse files
committed
Yonmoque: Add unit test
1 parent f90a5fc commit 1e53e16

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

test/games/yonmoque.test.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/* eslint-disable no-unused-expressions */
2+
/* eslint-disable @typescript-eslint/no-unused-expressions */
3+
4+
import "mocha";
5+
import { expect } from "chai";
6+
import { YonmoqueGame } from '../../src/games';
7+
8+
describe("Yonmoque", () => {
9+
it ("Placing doesn't flip", () => {
10+
const g = new YonmoqueGame();
11+
g.board.set("a1", 1);
12+
g.board.set("a2", 2);
13+
g.move("a3");
14+
expect(g.board.get("a2")).to.equal(2);
15+
});
16+
it ("Moving does", () => {
17+
const g = new YonmoqueGame();
18+
g.board.set("a1", 1);
19+
g.board.set("a2", 2);
20+
g.board.set("a4", 1)
21+
g.move("a4-a3");
22+
expect(g.board.get("a2")).to.equal(1);
23+
});
24+
it ("Placing a fifth loses", () => {
25+
const g = new YonmoqueGame();
26+
g.board.set("a1", 1);
27+
g.board.set("a2", 1);
28+
g.board.set("a3", 1);
29+
g.board.set("a4", 1);
30+
g.move("a5");
31+
expect(g.gameover).to.be.true;
32+
expect(g.winner).to.have.members([2]);
33+
});
34+
it ("Moving a fifth loses", () => {
35+
const g = new YonmoqueGame();
36+
g.board.set("a1", 1);
37+
g.board.set("a2", 1);
38+
g.board.set("a3", 1);
39+
g.board.set("a4", 1);
40+
g.board.set("b5", 1);
41+
g.move("b5-a5");
42+
expect(g.gameover).to.be.true;
43+
expect(g.winner).to.have.members([2]);
44+
});
45+
it ("Placing a fourth does nothing", () => {
46+
const g = new YonmoqueGame();
47+
g.board.set("a1", 1);
48+
g.board.set("a2", 1);
49+
g.board.set("a3", 1);
50+
g.move("a4");
51+
expect(g.gameover).to.be.false;
52+
});
53+
it ("Moving a fourth wins", () => {
54+
const g = new YonmoqueGame();
55+
g.board.set("a1", 1);
56+
g.board.set("a2", 1);
57+
g.board.set("a3", 1);
58+
g.board.set("b4", 1);
59+
g.move("b4-a4");
60+
expect(g.gameover).to.be.true;
61+
expect(g.winner).to.have.members([1]);
62+
});
63+
});
64+

0 commit comments

Comments
 (0)