From e30259bb228ff5011998b1b9dbaf2508b0047425 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 13 Mar 2022 14:05:22 +0300 Subject: feat: add test to manually verify attachments --- src/Board/Board.test.ts | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'src/Board/Board.test.ts') diff --git a/src/Board/Board.test.ts b/src/Board/Board.test.ts index 349a4aa..5023f0b 100644 --- a/src/Board/Board.test.ts +++ b/src/Board/Board.test.ts @@ -1,10 +1,11 @@ +import _ from 'lodash'; import assert from 'assert'; import Tile, { Feature, Direction } from '../Tile/Tile'; import TileOnBoard from '../Tile/TileOnBoard'; import Board from './Board'; const { Road, Town, Grass } = Feature; -const { North } = Direction; +const { North, East } = Direction; describe('Board', () => { describe('constructor', () => { @@ -23,10 +24,33 @@ describe('Board', () => { 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 }); + assert.deepStrictEqual(legalMoves[0], { side: 0, orientation: 1, attachTo, tile }); + assert.deepStrictEqual(legalMoves[1], { side: 0, orientation: 3, attachTo, tile }); + assert.deepStrictEqual(legalMoves[2], { side: 2, orientation: 0, attachTo, tile }); + assert.deepStrictEqual(legalMoves[3], { side: 2, orientation: 2, attachTo, tile }); + }); + + it.skip('Have a look at my nice attachments manually bro', () => { + const board = new Board(); + + board.attach({ + tile: new Tile(Town, [Town, Grass, Town, Grass]), + attachTo: board.tiles[0], + orientation: 0, + side: North, + }); + + board.attach({ + tile: new Tile(Town, [Road, Town, Town, Road]), + attachTo: board.tiles[0], + orientation: 0, + side: East, + }); + + const tile = new Tile(Grass, [Town, Grass, Grass, Grass]); + + const attachments = board.getAttachments(tile); + attachments.forEach(attachment => board.previewAttachment(attachment)); }); }); @@ -50,6 +74,7 @@ describe('Board', () => { ); board.attach(attachment); + assert.strictEqual(board.tiles.length, 2); assert.deepStrictEqual(board.tiles[1], expectedTileOnBoard); }); -- cgit v1.2.3