Commit d426e31e authored by Maxime PERRIN's avatar Maxime PERRIN
Browse files

test rook aucune failure

parent 6d5957a9
......@@ -411,41 +411,73 @@ describe("Test rookMove()", () => {
beforeEach( () => {
// TODO:
// Initialize an empty chessboard
chessboard = createEmptyChessboard();
// Place a white Rook on E4
putPiece(chessboard, positionE4, pieces.whiteRoock);
});
it("A roock can move horizontally", () => {
// TODO:
// Check the following moves are possible: moveE4_H4, moveE4_A4
let horizontalRightMove = {from: positionE4, to: positionH4, isValid: true};
expect(isPossible.rookMove(chessboard, horizontalRightMove)).toBeTruthy();
let horizontalLeftMove = {from: positionE4, to: positionA4, isValid: true};
expect(isPossible.rookMove(chessboard, horizontalLeftMove)).toBeTruthy();
});
it("A roock can move vertically", () => {
// TODO:
// Check the following moves are possible: moveE4_E1, moveE4_E8
let verticalForwardMove = {from: positionE4, to: positionE1, isValid: true};
expect(isPossible.rookMove(chessboard, verticalForwardMove)).toBeTruthy();
let verticalBackwardMove = {from: positionE4, to: positionE8, isValid: true};
expect(isPossible.rookMove(chessboard, verticalBackwardMove)).toBeTruthy();
});
it("A roock cannot move diagonally", () => {
// TODO:
// Check the following moves are impossible:
// moveE4_A8, moveE4_B1, moveE4_H7, moveE4_H1
let diagonalForwardLeftMove = {from: positionE4, to: positionA8, isValid: true};
expect(isPossible.rookMove(chessboard, diagonalForwardLeftMove)).toBeFalsy();
let diagonalForwardRightMove = {from: positionE4, to: positionH7, isValid: true};
expect(isPossible.rookMove(chessboard, diagonalForwardRightMove)).toBeFalsy();
let diagonalBackwardLeftMove = {from: positionE4, to: positionB1, isValid: true};
expect(isPossible.rookMove(chessboard, diagonalBackwardLeftMove)).toBeFalsy();
let diagonalBackwardRightMove = {from: positionE4, to: positionH1, isValid: true};
expect(isPossible.rookMove(chessboard, diagonalBackwardRightMove)).toBeFalsy();
});
it("A roock can capture a piece from another color", () => {
// TODO:
// Place a black Pawn on H4
putPiece(chessboard, positionH4, pieces.blackPawn);
// Check the move moveE4_H4 is possible
let canCapture: Move = {from: positionE4, to: positionH4, isValid: true}
expect(isPossible.rookMove(chessboard, canCapture)).toBeTruthy();
});
it("A roock cannot capture a piece from the same color", () => {
// TODO:
// Place a white Pawn on H4
putPiece(chessboard, positionH4, pieces.whitePawn);
// Check the move moveE4_H4 is impossible
let cannotCapture: Move = {from: positionE4, to: positionH4, isValid: true}
expect(isPossible.rookMove(chessboard, cannotCapture)).toBeFalsy();
});
it("A Roock cannot leap other pieces", () => {
// TODO:
// Place a black Pawn on F4
putPiece(chessboard, positionF4, pieces.blackPawn);
// Check the move moveE4_H4 is impossible
let cannotCapture: Move = {from: positionE4, to: positionH4, isValid: true}
expect(isPossible.rookMove(chessboard, cannotCapture)).toBeFalsy();
});
});
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment