Skip to content

Commit

Permalink
[#122] Minor fixes to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ido-Barnea committed Jan 9, 2024
1 parent b6e2253 commit 2d5aecb
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Player, PlayerColors } from '../Players';
import { Position } from './PiecesHelpers';
import { Position } from '../pieces/PiecesHelpers';

export const whitePlayer = new Player(PlayerColors.WHITE);
export const blackPlayer = new Player(PlayerColors.BLACK);
export const items = [];

function comparePositions(
export function comparePositions(
firstPosition: Position,
secondPosition: Position,
): boolean {
Expand All @@ -16,10 +16,13 @@ function comparePositions(
return areBoardsEqual && arePositionsEqual;
}

export const mockedLogic = {
getCurrentPlayer: () => whitePlayer,
switchIsCastling: jest.fn(),
items: [],
comparePositions: comparePositions,
getPieceByPositionAndBoard: () => undefined,
// eslint-disable-next-line @typescript-eslint/no-empty-function
export function switchIsCastling() {}

export function getPieceByPositionAndBoard() {
return undefined;
};

export function getCurrentPlayer() {
return whitePlayer;
}
6 changes: 4 additions & 2 deletions development/src/logic/pieces/Bishop.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { OVERWORLD_BOARD_ID } from '../Constants';
import { Player, PlayerColors } from '../Players';
import { Bishop } from './Bishop';
import { Position } from './PiecesHelpers';
import { mockedLogic, whitePlayer } from './mocks';

jest.mock('../Logic.ts', () => mockedLogic);
jest.mock('../Logic.ts');

const whitePlayer = new Player(PlayerColors.WHITE);

describe('Piece movements', () => {
test('Validating Bishop movement', () => {
Expand Down
6 changes: 4 additions & 2 deletions development/src/logic/pieces/King.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { OVERWORLD_BOARD_ID } from '../Constants';
import { Player, PlayerColors } from '../Players';
import { King } from './King';
import { Position } from './PiecesHelpers';
import { mockedLogic, whitePlayer } from './mocks';

jest.mock('../Logic', () => mockedLogic);
jest.mock('../Logic');

const whitePlayer = new Player(PlayerColors.WHITE);

describe('Piece movements', () => {
test('Validating King movement', () => {
Expand Down
6 changes: 4 additions & 2 deletions development/src/logic/pieces/Knight.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { OVERWORLD_BOARD_ID } from '../Constants';
import { Player, PlayerColors } from '../Players';
import { Knight } from './Knight';
import { Position } from './PiecesHelpers';
import { mockedLogic, whitePlayer } from './mocks';

jest.mock('../Logic', () => mockedLogic);
jest.mock('../Logic');

const whitePlayer = new Player(PlayerColors.WHITE);

describe('Piece movements', () => {
test('Validating Knight movement', () => {
Expand Down
7 changes: 5 additions & 2 deletions development/src/logic/pieces/Pawn.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { OVERWORLD_BOARD_ID } from '../Constants';
import { Player, PlayerColors } from '../Players';
import { Pawn } from './Pawn';
import { Position } from './PiecesHelpers';
import { mockedLogic, blackPlayer, whitePlayer } from './mocks';

jest.mock('../Logic', () => mockedLogic);
jest.mock('../Logic');

const whitePlayer = new Player(PlayerColors.WHITE);
const blackPlayer = new Player(PlayerColors.BLACK);

describe('Piece movements', () => {
test('Validating Pawn movement', () => {
Expand Down
6 changes: 4 additions & 2 deletions development/src/logic/pieces/Queen.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { OVERWORLD_BOARD_ID } from '../Constants';
import { Player, PlayerColors } from '../Players';
import { Position } from './PiecesHelpers';
import { Queen } from './Queen';
import { mockedLogic, whitePlayer } from './mocks';

jest.mock('../Logic', () => mockedLogic);
jest.mock('../Logic');

const whitePlayer = new Player(PlayerColors.WHITE);

describe('Piece movements', () => {
test('Validating Queen movement', () => {
Expand Down
6 changes: 4 additions & 2 deletions development/src/logic/pieces/Rook.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { OVERWORLD_BOARD_ID } from '../Constants';
import { Player, PlayerColors } from '../Players';
import { Position } from './PiecesHelpers';
import { Rook } from './Rook';
import { mockedLogic, whitePlayer } from './mocks';

jest.mock('../Logic', () => mockedLogic);
jest.mock('../Logic');

const whitePlayer = new Player(PlayerColors.WHITE);

describe('Piece movements', () => {
test('Validating Rook movement', () => {
Expand Down

0 comments on commit 2d5aecb

Please sign in to comment.