diff --git a/tests/MancalaGame.test.ts b/tests/MancalaGame.test.ts index 475c019..27597a8 100644 --- a/tests/MancalaGame.test.ts +++ b/tests/MancalaGame.test.ts @@ -1,29 +1,6 @@ -import { GRClearBoardAtEnd } from '../src/common/game_rules/GRClearBoardAtEnd'; -import { GRLastStoneInBank } from '../src/common/game_rules/GRLastStoneInBank'; -import { GRLastStoneInEmptyPit } from '../src/common/game_rules/GRLastStoneInEmptyPit'; -import { Board } from '../src/core/Board'; -import { MoveHistoryItem } from '../src/core/HistoryItem'; -import { MancalaGame } from '../src/core/MancalaGame'; - -function createGame(): MancalaGame { - const board = new Board(6, 4); - const player1Id = '0'; - const player2Id = '1'; - const game = new MancalaGame( - '0', - board, - player1Id, - player2Id, - player1Id, - [ - new GRLastStoneInEmptyPit(), - new GRLastStoneInBank(), - new GRClearBoardAtEnd() - ], - [] - ); - return game; -} +import { GameStep, MoveHistoryItem } from '../src/core/HistoryItem'; +import { GAME_STEP_GAME_MOVE, MancalaGame } from '../src/core/MancalaGame'; +import { createGame } from './TestUtil'; describe('Game Test', () => { test('test getPlayerIdByIndex', () => { diff --git a/tests/TestUtil.ts b/tests/TestUtil.ts new file mode 100644 index 0000000..dc338ce --- /dev/null +++ b/tests/TestUtil.ts @@ -0,0 +1,25 @@ +import { GRClearBoardAtEnd } from '../src/common/game_rules/GRClearBoardAtEnd'; +import { GRLastStoneInBank } from '../src/common/game_rules/GRLastStoneInBank'; +import { GRLastStoneInEmptyPit } from '../src/common/game_rules/GRLastStoneInEmptyPit'; +import { Board } from '../src/core/Board'; +import { MancalaGame } from '../src/core/MancalaGame'; + +export function createGame(): MancalaGame { + const board = new Board(6, 4); + const player1Id = '0'; + const player2Id = '1'; + const game = new MancalaGame( + '0', + board, + player1Id, + player2Id, + player1Id, + [ + new GRLastStoneInEmptyPit(), + new GRLastStoneInBank(), + new GRClearBoardAtEnd() + ], + [] + ); + return game; +} diff --git a/tests/game_rules/GRClearBoardAtEnd.test.ts b/tests/game_rules/GRClearBoardAtEnd.test.ts index a54f2fd..b73ef58 100644 --- a/tests/game_rules/GRClearBoardAtEnd.test.ts +++ b/tests/game_rules/GRClearBoardAtEnd.test.ts @@ -1,28 +1,19 @@ -import { GRLastStoneInBank } from '../../src/common/game_rules/GRLastStoneInBank'; -import { GRLastStoneInEmptyPit } from '../../src/common/game_rules/GRLastStoneInEmptyPit'; -import { GRClearBoardAtEnd } from '../../src/common/game_rules/GRClearBoardAtEnd'; +import { + GAME_STEP_LAST_STONE_IN_BANK, + GRLastStoneInBank +} from '../../src/common/game_rules/GRLastStoneInBank'; +import { + GAME_STEP_LAST_STONE_IN_EMPTY_PIT, + GRLastStoneInEmptyPit +} from '../../src/common/game_rules/GRLastStoneInEmptyPit'; +import { + GAME_STEP_BOARD_CLEARED, + GRClearBoardAtEnd +} from '../../src/common/game_rules/GRClearBoardAtEnd'; import { Board } from '../../src/core/Board'; -import { MancalaGame } from '../../src/core/MancalaGame'; - -function createGame(): MancalaGame { - const board = new Board(6, 4); - const player1Id = '0'; - const player2Id = '1'; - const game = new MancalaGame( - '0', - board, - player1Id, - player2Id, - player1Id, - [ - new GRLastStoneInEmptyPit(), - new GRLastStoneInBank(), - new GRClearBoardAtEnd() - ], - [] - ); - return game; -} +import { GAME_STEP_GAME_MOVE, MancalaGame } from '../../src/core/MancalaGame'; +import { GameStep } from '../../src/core/HistoryItem'; +import { createGame } from '../TestUtil'; describe('GRClearBoardAtEnd Test', () => { test('test GRClearBoardAtEnd 1', () => {