Commit aca5daff authored by Teddy BARKOU's avatar Teddy BARKOU
Browse files

debut jasmine

parent 8ce4e572
......@@ -6,6 +6,9 @@ import { Move, move } from '../src/movements';
let chessboard : Chessboard;
const positionA1 : Position = position(0, 0) // A1
const positionA2 : Position = position(0, 1) // A2
const positionA3 : Position = position(0, 2) // A3
const positionA4 : Position = position(0, 3) // A4
const positionA5 : Position = position(0, 4) // A5
const positionA6 : Position = position(0, 5) // A6
......@@ -14,29 +17,68 @@ const positionA8 : Position = position(0, 7) // A8
const positionB1 : Position = position(1, 0) // B1
const positionB2 : Position = position(1, 1) // B2
const positionB3 : Position = position(1, 2) // B3
const positionB4 : Position = position(1, 3) // B4
const positionB5 : Position = position(1, 4) // B5
const positionB6 : Position = position(1, 5) // B6
const positionB7 : Position = position(1, 6) // B7
const positionB8 : Position = position(1, 7) // B8
const positionC3 : Position = position(2, 1) // C3
const positionC1 : Position = position(2, 0) // C1
const positionC2 : Position = position(2, 1) // C2
const positionC3 : Position = position(2, 2) // C3
const positionC4 : Position = position(2, 3) // C4
const positionC5 : Position = position(2, 4) // C5
const positionC6 : Position = position(2, 5) // C6
const positionC7 : Position = position(2, 6) // C7
const positionC8 : Position = position(2, 7) // C8
const positionD1 : Position = position(3, 0) // D1
const positionD2 : Position = position(3, 1) // D2
const positionD3 : Position = position(3, 2) // D3
const positionD4 : Position = position(3, 3) // D4
const positionD5 : Position = position(3, 4) // D5
const positionD6 : Position = position(3, 5) // D6
const positionD7 : Position = position(3, 6) // D7
const positionD8 : Position = position(3, 7) // D8
const positionE1 : Position = position(4, 0) // E1
const positionE2 : Position = position(4, 1) // E2
const positionE3 : Position = position(4, 2) // E3
const positionE4 : Position = position(4, 3) // E4
const positionE5 : Position = position(4, 4) // E5
const positionE6 : Position = position(4, 5) // E6
const positionE7 : Position = position(4, 6) // E7
const positionE8 : Position = position(4, 7) // E8
const positionF1 : Position = position(5, 0) // F1
const positionF2 : Position = position(5, 1) // F2
const positionF3 : Position = position(5, 2) // F3
const positionF4 : Position = position(5, 3) // F4
const positionF5 : Position = position(5, 4) // F5
const positionF6 : Position = position(5, 5) // F6
const positionF7 : Position = position(5, 6) // F7
const positionF8 : Position = position(5, 7) // F8
const positionG1 : Position = position(6, 0) // G1
const positionG2 : Position = position(6, 1) // G2
const positionG3 : Position = position(6, 2) // G3
const positionG4 : Position = position(6, 3) // G4
const positionG5 : Position = position(6, 4) // G5
const positionG6 : Position = position(6, 5) // G6
const positionG7 : Position = position(6, 6) // G7
const positionG8 : Position = position(6, 7) // G8
const positionH1 : Position = position(7, 0) // H1
const positionH2 : Position = position(7, 1) // H2
const positionH3 : Position = position(7, 2) // H3
const positionH4 : Position = position(7, 3) // H4
const positionH7 : Position = position(7, 8) // H7
const positionH5 : Position = position(7, 4) // H5
const positionH6 : Position = position(7, 5) // H6
const positionH7 : Position = position(7, 6) // H7
const positionH8 : Position = position(7, 7) // H8
// Horizontal moves
const moveE4_H4 : Move = move(positionE4, positionH4);
......@@ -192,16 +234,84 @@ describe("Test whitePawnMove()", () => {
describe("Test kingMove()", () => {
beforeEach( () => {
// TODO:
chessboard = createEmptyChessboard();
})
it("king can move up", () => {
putPiece(chessboard, positionE4, pieces.blackKing);
let up : Move = {from: positionE4, to: positionE5, isValid: true};
expect(isPossible.blackPawnMove(chessboard, up)).toBeTruthy();
});
it("king can move down", () => {
putPiece(chessboard, positionE4, pieces.blackKing);
let singleForward: Move = {from: positionE4, to: positionE3, isValid: true};
expect(isPossible.blackPawnMove(chessboard, singleForward)).toBeTruthy();
});
it("king can move left", () => {
putPiece(chessboard, positionE4, pieces.blackKing);
let singleForward: Move = {from: positionE4, to: positionD4, isValid: true};
expect(isPossible.blackPawnMove(chessboard, singleForward)).toBeTruthy();
});
it("king can move right", () => {
putPiece(chessboard, positionE4, pieces.blackKing);
let singleForward: Move = {from: positionE4, to: positionF4, isValid: true};
expect(isPossible.blackPawnMove(chessboard, singleForward)).toBeTruthy();
});
it("king can move up left", () => {
putPiece(chessboard, positionE4, pieces.blackKing);
let singleForward: Move = {from: positionE4, to: positionD5, isValid: true};
expect(isPossible.blackPawnMove(chessboard, singleForward)).toBeTruthy();
});
it("king can move down left", () => {
putPiece(chessboard, positionE4, pieces.blackKing);
let singleForward: Move = {from: positionE4, to: positionD3, isValid: true};
expect(isPossible.blackPawnMove(chessboard, singleForward)).toBeTruthy();
});
it("king can move down right", () => {
putPiece(chessboard, positionE4, pieces.blackKing);
let singleForward: Move = {from: positionE4, to: positionF3, isValid: true};
expect(isPossible.blackPawnMove(chessboard, singleForward)).toBeTruthy();
});
it("king can move up rigth", () => {
putPiece(chessboard, positionE4, pieces.blackKing);
let singleForward: Move = {from: positionE4, to: positionF5, isValid: true};
expect(isPossible.blackPawnMove(chessboard, singleForward)).toBeTruthy();
});
// Initialize an empty chessboard
// Place a black King on E4
});
it("A King can move 1 square in all directions", () => {
// Check it can move to squares D3, D4, D5, E3, E5, F3, F4, and F5
})
it("A King cannot move more than 1 square", () => {
// Check it cannot move to squares C2, C3, C4, C6, D4, and F4
putPiece(chessboard, positionE4, pieces.blackKing);
let longForward: Move = {from: positionE4, to: positionC2, isValid: true};
expect(isPossible.blackPawnMove(chessboard, longForward)).toBeFalsy();
putPiece(chessboard, positionE4, pieces.blackKing);
longForward = {from: positionE4, to: positionC3, isValid: true};
expect(isPossible.blackPawnMove(chessboard, longForward)).toBeFalsy();
putPiece(chessboard, positionE4, pieces.blackKing);
longForward = {from: positionE4, to: positionC4, isValid: true};
expect(isPossible.blackPawnMove(chessboard, longForward)).toBeFalsy();
putPiece(chessboard, positionE4, pieces.blackKing);
longForward = {from: positionE4, to: positionC6, isValid: true};
expect(isPossible.blackPawnMove(chessboard, longForward)).toBeFalsy();
putPiece(chessboard, positionE4, pieces.blackKing);
longForward = {from: positionE4, to: positionC5, isValid: true};
expect(isPossible.blackPawnMove(chessboard, longForward)).toBeFalsy();
putPiece(chessboard, positionE4, pieces.blackKing);
longForward = {from: positionE4, to: positionC7, isValid: true};
expect(isPossible.blackPawnMove(chessboard, longForward)).toBeFalsy();
})
it("A King cannot capure pieces from the same color", () => {
......
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