mancala/tests/mancala.test.js

31 lines
1.9 KiB
JavaScript
Raw Normal View History

2021-06-29 03:26:23 +03:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var mancala_1 = require("../src/mancala");
describe('mancala', function () {
var player1 = "0";
var player2 = "0";
it('turn test', function () {
var game = mancala_1.createGame(player1, player2);
game.turn = "player1";
game.moveByIndex(3, "player1");
expect(game.turn).toBe("player1");
});
it('zero hole test 1', function () {
var board = new mancala_1.Board([new mancala_1.Hole(0), new mancala_1.Hole(1), new mancala_1.Hole(2), new mancala_1.Hole(3), new mancala_1.Hole(4), new mancala_1.Hole(5)], [new mancala_1.Hole(1), new mancala_1.Hole(0), new mancala_1.Hole(4), new mancala_1.Hole(4), new mancala_1.Hole(4), new mancala_1.Hole(4)], new mancala_1.Store(0), new mancala_1.Store(0));
2021-06-30 19:27:38 +03:00
var game = new mancala_1.Game(player1, player2, board, "player2", "playing");
2021-06-29 03:26:23 +03:00
game.moveByIndex(0, "player2");
expect(game.turn).toBe("player1");
expect(game.board.player2Store.ballCount).toBe(5);
expect(game.board.player1Holes[game.board.player1Holes.length - 1 - 1].ballCount).toBe(0);
});
2021-06-30 19:27:38 +03:00
it('game end test 1', function () {
var board = new mancala_1.Board([new mancala_1.Hole(0), new mancala_1.Hole(0), new mancala_1.Hole(0), new mancala_1.Hole(0), new mancala_1.Hole(4), new mancala_1.Hole(4)], [new mancala_1.Hole(0), new mancala_1.Hole(0), new mancala_1.Hole(0), new mancala_1.Hole(0), new mancala_1.Hole(0), new mancala_1.Hole(1)], new mancala_1.Store(0), new mancala_1.Store(0));
var game = new mancala_1.Game(player1, player2, board, "player2", "playing");
game.moveByIndex(5, "player2");
expect(game.turn).toBe("player2");
expect(game.board.player2Store.ballCount).toBe(9);
expect(game.board.player1Holes[game.board.player1Holes.length / 2].ballCount).toBe(0);
expect(game.state).toBe("ended");
});
2021-06-29 03:26:23 +03:00
});
//# sourceMappingURL=mancala.test.js.map