1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import assert from 'assert';
import Tile, { Feature } from '../Tile/Tile';
import Board from "./Board";
const { Road, Town, Empty } = Feature;
describe('Board', () => {
describe('constructor', () => {
it('Should initialize empty board with a starting cell', () => {
const board = new Board();
assert.strictEqual(board.cells.length, 1);
assert.deepStrictEqual(board.cells[0], new Tile(Road, [Town, Road, Empty, Road]));
});
});
describe('getAttachments', () => {
it('Should correctly determine legal moves for 1-cell board', () => {
const board = new Board();
const attachTo = board.cells[0];
const cell = new Tile(Town, [Empty, Town, Empty, Town]);
const legalMoves = board.getAttachments(cell);
assert.strictEqual(legalMoves.length, 4);
assert.deepStrictEqual(legalMoves[0], { side: 0, rotation: 1, attachTo, cell });
assert.deepStrictEqual(legalMoves[1], { side: 0, rotation: 3, attachTo, cell });
assert.deepStrictEqual(legalMoves[2], { side: 2, rotation: 0, attachTo, cell });
assert.deepStrictEqual(legalMoves[3], { side: 2, rotation: 2, attachTo, cell });
});
});
});
|