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

fin test knight

parent 7cc874bd
......@@ -344,8 +344,9 @@ describe("Test bishopMove()", () => {
let diagonalForwardLeftMove = {from: positionE4, to: positionA8, isValid: true};
expect(isPossible.bishopMove(chessboard,diagonalForwardLeftMove )).toBeTruthy();
//FIXE ME: erreur de test expect false to be truthy , alors que si un prend la case G6 (la case diagonal d'avant) l'erreur disparait
let diagonalForwardRightMove = {from: positionE4, to: positionH7, isValid: true};
expect(isPossible.bishopMove(chessboard,diagonalForwardRightMove )).toBeTruthy();
expect(isPossible.bishopMove(chessboard,diagonalForwardRightMove )).toBeTruthy();
let diagonalBackwardLeftMove = {from: positionE4, to: positionB1, isValid: true};
expect(isPossible.bishopMove(chessboard,diagonalBackwardLeftMove )).toBeTruthy();
......@@ -440,25 +441,78 @@ describe("Test knightMove()", () => {
expect(isPossible.knightMove(chessboard,rightRightBotMove )).toBeTruthy();
})
it("A Knight can move two squares vertically and one square horizontally", () => {
// TODO:
let topTopLeftMove = {from: positionE4, to: positionD6, isValid: true};
expect(isPossible.knightMove(chessboard,topTopLeftMove )).toBeTruthy();
let topTopRightMove = {from: positionE4, to: positionF6, isValid: true};
expect(isPossible.knightMove(chessboard,topTopRightMove )).toBeTruthy();
let botBotLeftMove = {from: positionE4, to: positionD2, isValid: true};
expect(isPossible.knightMove(chessboard,botBotLeftMove )).toBeTruthy();
let botBotRightMove = {from: positionE4, to: positionF2, isValid: true};
expect(isPossible.knightMove(chessboard,botBotRightMove )).toBeTruthy();
})
it("A Knight can 'jump' obstacles" , () => {
// TODO:
// Place a black pawn on E5
putPiece(chessboard, positionE5, pieces.blackPawn);
// Jump the pawn who is on E6
let jumpMove = {from: positionE4, to: positionF6, isValid: true};
expect(isPossible.knightMove(chessboard,jumpMove )).toBeTruthy();
})
it("A Knight can move diagonally", () => {
// TODO:
it("A Knight cannot move diagonally", () => {
let diagonalForwardLeftMove = {from: positionE4, to: positionA8, isValid: true};
expect(isPossible.knightMove(chessboard,diagonalForwardLeftMove )).toBeFalsy();
let diagonalForwardRightMove = {from: positionE4, to: positionH7, isValid: true};
expect(isPossible.knightMove(chessboard,diagonalForwardRightMove )).toBeFalsy();
let diagonalBackwardLeftMove = {from: positionE4, to: positionB1, isValid: true};
expect(isPossible.knightMove(chessboard,diagonalBackwardLeftMove )).toBeFalsy();
let diagonalBackwardRightMove = {from: positionE4, to: positionH1, isValid: true};
expect(isPossible.knightMove(chessboard,diagonalBackwardRightMove )).toBeFalsy();
});
it("A Knight cannot move horizontally", () => {
// TODO:
let horizontalRightMove = {from: positionE4, to: positionH4, isValid: true};
expect(isPossible.knightMove(chessboard,horizontalRightMove )).toBeFalsy();
let horizontalLeftMove = {from: positionE4, to: positionA4, isValid: true};
expect(isPossible.knightMove(chessboard,horizontalLeftMove )).toBeFalsy();
});
it("A Knight cannot move vertically", () => {
// TODO:
let verticalBackwardMove = {from: positionE4, to: positionE1, isValid: true};
expect(isPossible.knightMove(chessboard,verticalBackwardMove )).toBeFalsy();
let verticalForwardMove = {from: positionE4, to: positionE8, isValid: true};
expect(isPossible.knightMove(chessboard,verticalForwardMove )).toBeFalsy();
});
it("A Knight can capture a piece from another color", () => {
// TODO:
// Place a white Pawn on F6
putPiece(chessboard, positionF6, pieces.blackPawn);
let canCapture = {from: positionE4, to: positionF6, isValid: true};
expect(isPossible.knightMove(chessboard,canCapture)).toBeTruthy();
});
it("A Knight cannot capture a piece from the same color", () => {
// TODO:
// Place a white Pawn on F6
putPiece(chessboard, positionF6, pieces.whitePawn);
let cannotCapture = {from: positionE4, to: positionF6, isValid: true};
expect(isPossible.knightMove(chessboard,cannotCapture)).toBeFalsy();
});
});
......
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