forked from Checkora/Checkora
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboard.test.js
More file actions
94 lines (84 loc) · 2.75 KB
/
board.test.js
File metadata and controls
94 lines (84 loc) · 2.75 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
document.body.innerHTML = `
<div id="board"></div>
<div id="turnBadge"></div>
<div id="statusBar"></div>
<div id="movesList"></div>
<div id="whiteCaptured"></div>
<div id="blackCaptured"></div>
<button id="pauseBtn"></button>
<div id="promoOverlay"></div>
<div id="promoChoices"></div>
<div id="modeBadge"></div>
<button id="autoFlipBtn"></button>
<div id="flipControls"></div>
<button id="copyFenBtn"></button>
<div id="welcomeOverlay"></div>
<button id="welcomeResumeBtn"></button>
<button id="welcomePvPBtn"></button>
<button id="welcomeAIBtn"></button>
<div id="modeSelection"></div>
<div id="pveOptions"><button class="color-choice" data-color="white"></button></div>
<button id="startAIBtn"></button>
<button id="backToModes"></button>
<div class="game-layout"></div>
<div id="confirmOverlay"></div>
<div id="confirmTitle"></div>
<div id="confirmMessage"></div>
<button id="confirmYesBtn"></button>
<button id="confirmNoBtn"></button>
<button id="newPvPBtn"></button>
<button id="newAIBtn"></button>
<div id="gameOverOverlay"><div class="promo-dialog"></div></div>
<div id="gameOverTitle"></div>
<div id="gameOverMessage"></div>
<button id="gameOverStartBtn"></button>
<button id="gameOverPvPBtn"></button>
<button id="gameOverAIBtn"></button>
<button id="resignBtn"></button>
<button id="drawBtn"></button>
<div id="drawOverlay"></div>
<div id="drawMessage"></div>
<button id="drawAcceptBtn"></button>
<button id="drawDeclineBtn"></button>
<div id="whiteNameLabel"></div>
<div id="blackNameLabel"></div>
<div id="whiteYouTag"></div>
<div id="blackYouTag"></div>
<div id="whiteCapturedName"></div>
<div id="blackCapturedName"></div>
<div id="turnBadgeText"></div>
`;
const { pColor, getSquareLabel, formatTime } = require("./game/static/game/js/board");
describe("pColor", () => {
test("returns white for uppercase piece", () => {
expect(pColor("K")).toBe("white");
});
test("returns black for lowercase piece", () => {
expect(pColor("k")).toBe("black");
});
test("returns null for empty piece", () => {
expect(pColor(null)).toBe(null);
});
});
describe("getSquareLabel", () => {
test("returns a8 for row 0 col 0", () => {
expect(getSquareLabel(0, 0)).toBe("a8");
});
test("returns e4 for row 4 col 4", () => {
expect(getSquareLabel(4, 4)).toBe("e4");
});
test("returns h1 for row 7 col 7", () => {
expect(getSquareLabel(7, 7)).toBe("h1");
});
});
describe("formatTime", () => {
test("formats 125 seconds as 2:05", () => {
expect(formatTime(125)).toBe("2:05");
});
test("formats 65 seconds as 1:05", () => {
expect(formatTime(65)).toBe("1:05");
});
test("formats 0 seconds as 0:00", () => {
expect(formatTime(0)).toBe("0:00");
});
});