import { test as base, expect } from 'vitest' import { Cell } from '.' import { CellGrid } from '../structures' interface TestFixture { grid: CellGrid } const test = base.extend({ grid: CellGrid.default(10) }) test('It should be initialized with default values', ({ grid }) => { const cell = grid.getCell([0, 0])! expect(cell.energy).toBeCloseTo(0) expect(cell.color.toHex()).toBe('#ffffff') }) test('It should calculate the distance to another cell', ({ grid }) => { const cell = grid.getCell([0, 0])! const other = grid.getCell([0, 1])! expect(cell.distanceTo(other)).toBeCloseTo(1) }) test('It should get immediate neighboring cells', ({ grid }) => { const cell = grid.getCell([5, 5])! const neighbors = cell.getNeighbors(grid) const expectedNeighbors = [ [4,5], [6,5], [5,4], [5,6], ] expect(neighbors.map(cell => cell.location)).toEqual(expectedNeighbors) }) test('It should get immediate neighboring cells and include self', ({ grid }) => { const cell = grid.getCell([5, 5])! const neighbors = cell.getNeighbors(grid, { includeSelf: true }) const expectedNeighbors = [ [4,5], [6,5], [5,4], [5,6], [5,5], ] expect(neighbors.map(cell => cell.location)).toEqual(expectedNeighbors) }) test('It should include diagonal neighboring cells', ({ grid }) => { const cell = grid.getCell([5, 5])! const neighbors = cell.getNeighbors(grid, { includeDiagonals: true }) const expectedNeighbors = [ [4,5], [6,5], [5,4], [5,6], [4,4], [4,6], [6,4], [6,6], ] expect(neighbors.map(cell => cell.location)).toEqual(expectedNeighbors) })