-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect4.test.js
More file actions
41 lines (36 loc) · 826 Bytes
/
Copy pathconnect4.test.js
File metadata and controls
41 lines (36 loc) · 826 Bytes
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
describe('checks for end game', function (){
beforeEach(function (){
for (let row of board) {
row.fill(null);
}
});
it('should be able to check horizontal', function (){
for (let i = 0; i < 4; i++) {
board[5][i] = 1;
}
expect(checkForWin()).toEqual(true);
});
it('should be able to check vertical', function (){
for (let i = 1; i < 5; i++) {
board[i][3] = 1;
}
expect(checkForWin()).toEqual(true);
});
it('should be able to check diagnal', function (){
board[0][0] = 1;
board[1][1] = 1;
board[2][2] = 1;
board[3][3] = 1;
expect(checkForWin()).toEqual(true);
});
it('should be able to check for tie', function (){
board[0].fill(3);
expect(checkForTie()).toEqual(true);
});
afterAll(function (){
for (let row of board) {
row.fill(null);
}
currPlayer = 1;
});
});