-
Notifications
You must be signed in to change notification settings - Fork 0
/
tic-tac-toe.spec.js
55 lines (44 loc) · 1.38 KB
/
tic-tac-toe.spec.js
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
import { TicTacToe } from "./tic-tac-toe.js";
import assert from "assert";
/*
let test = new TicTacToe();
test.selectUpLeft();
test.selectDownLeft();
test.selectUpCenter();
test.selectDownRight();
test.selectUpRight();
test.selectUpLeft();
test.selectUpCenter();
test.selectUpRight();
test.selectCenterCenter();
test.selectCenterRight();
test.selectDownRight();
test.selectDownCenter();
test.selectDownLeft();
test.selectCenterLeft();
*/
console.log("-------------------test1-------------------");
(function test_getGameState_shouldInitiallyBeOpen() {
assert.equal(new TicTacToe().currentState, "open");
})();
console.log("-------------------test2-------------------");
(function test_currentPlayer_shouldInitiallyBePlayerOne() {
assert.equal(new TicTacToe().currentPlayer, "player1");
})();
console.log("-------------------test3-------------------");
(function test_act_shouldRefreshGameState_player1Won() {
const ttt = new TicTacToe();
ttt.selectUpLeft();
ttt.selectDownLeft();
ttt.selectUpCenter();
ttt.selectDownRight();
ttt.selectUpRight();
assert.equal(ttt.currentState, "player1won");
})();
console.log("-------------------test4-------------------");
function test_act_shouldReturnTextIfMoveIsInvalid() {
const ttt = new TicTacToe();
ttt.selectUpLeft();
assert.equal(ttt.selectUpLeft(), "This square is already occupied");
}
test_act_shouldReturnTextIfMoveIsInvalid();