From 2b6ba3f395cb62bef07f2cc12a00dab0c1cf2f04 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Fri, 11 Mar 2022 17:47:17 +0300 Subject: feat: implement getAttachments --- src/Cell/Cell.test.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/Cell/Cell.test.ts') diff --git a/src/Cell/Cell.test.ts b/src/Cell/Cell.test.ts index 56f227f..0931130 100644 --- a/src/Cell/Cell.test.ts +++ b/src/Cell/Cell.test.ts @@ -2,7 +2,7 @@ import assert from 'assert'; import Cell, { Direction, Item } from './Cell'; const { North, East, South, West } = Direction; -const { Road, Town, Empty, River, Church } = Item; +const { Road, Town, Empty, River } = Item; describe('Cell', () => { describe('getSide', () => { @@ -36,15 +36,17 @@ describe('Cell', () => { }); }); - describe('isAttachable', () => { - it('Should correctly test if cell is attachable', () => { - const cell = new Cell(Church, [Road, Town, Empty, River]); - const other = new Cell(Empty, [Road, Road, Town, Road], 3); - - assert.strictEqual(cell.isAttachable(other, North), true); - assert.strictEqual(cell.isAttachable(other, East), true); - assert.strictEqual(cell.isAttachable(other, South), false); - assert.strictEqual(cell.isAttachable(other, West), false); + describe('getAttachments', () => { + it('Should correclty list legal attachments', () => { + const attachTo = new Cell(Town, [Road, Town, Town, Road]) + const cell = new Cell(Road, [Empty, Road, Road, Empty]) + + const attachments = attachTo.getAttachments(cell); + assert.strictEqual(attachments.length, 4); + assert.deepStrictEqual(attachments[0], { side: 0, rotation: 0, cell, attachTo }); + assert.deepStrictEqual(attachments[1], { side: 0, rotation: 1, cell, attachTo }); + assert.deepStrictEqual(attachments[2], { side: 3, rotation: 0, cell, attachTo }); + assert.deepStrictEqual(attachments[3], { side: 3, rotation: 3, cell, attachTo }); }); }); }); -- cgit v1.2.3