import assert from 'assert'; import Tile from './Tile'; import { Direction } from './Tile'; const { North, East, South, West } = Direction; describe('Tile', () => { describe('getEdge', () => { it('Should get North, East, South and West edges correctly', () => { const tile = new Tile('F', 'RCFR'); assert.strictEqual(tile.edges[North], 'R'); assert.strictEqual(tile.edges[East], 'C'); assert.strictEqual(tile.edges[South], 'F'); assert.strictEqual(tile.edges[West], 'R'); }); it('Should respect tile orientation', () => { const tile = new Tile('F', 'RCFR'); tile.orientation = 5; assert.strictEqual(tile.edges, 'RRCF') }); it('Should work with negative orientation', () => { const tile = new Tile('F', 'RCFR'); tile.orientation = -7 assert.strictEqual(tile.edges, 'RRCF') }); }); describe('getAttachments', () => { it('Should correclty list legal attachments', () => { const attachTo = new Tile('C', 'RCCR') const tile = new Tile('R', 'FRRF') const attachments = attachTo.getAttachments(tile); assert.strictEqual(attachments.length, 4); assert.deepStrictEqual(attachments[0], { edge: 0, orientation: 1, tile, attachTo }); assert.deepStrictEqual(attachments[1], { edge: 0, orientation: 0, tile, attachTo }); assert.deepStrictEqual(attachments[2], { edge: 3, orientation: 0, tile, attachTo }); assert.deepStrictEqual(attachments[3], { edge: 3, orientation: 3, tile, attachTo }); }); }); });