import assert from 'assert'; import Tile, { Feature } from '../Tile/Tile'; import TileOnBoard from '../Tile/TileOnBoard'; import Board from './Board'; const { Road, Town, Empty } = Feature; describe('Board', () => { describe('constructor', () => { it('Should initialize empty board with a starting tile', () => { const board = new Board(); assert.strictEqual(board.tiles.length, 1); assert.deepStrictEqual(board.tiles[0], new TileOnBoard(Road, [Town, Road, Empty, Road])); }); }); describe('getAttachments', () => { it('Should correctly determine legal moves for 1-tile board', () => { const board = new Board(); const attachTo = board.tiles[0]; const tile = new Tile(Town, [Empty, Town, Empty, Town]); const legalMoves = board.getAttachments(tile); assert.strictEqual(legalMoves.length, 4); assert.deepStrictEqual(legalMoves[0], { side: 0, rotation: 1, attachTo, tile }); assert.deepStrictEqual(legalMoves[1], { side: 0, rotation: 3, attachTo, tile }); assert.deepStrictEqual(legalMoves[2], { side: 2, rotation: 0, attachTo, tile }); assert.deepStrictEqual(legalMoves[3], { side: 2, rotation: 2, attachTo, tile }); }); }); });