import { describe, it, expect } from 'vitest'; import { getHexesInBounds, hexAtPixel } from '@core/hex-grid'; describe('getHexesInBounds', () => { const size = 32; it('returns hexes covering a small area', () => { const hexes = getHexesInBounds( { minX: 0, minY: 0, maxX: 100, maxY: 100 }, size, ); expect(hexes.length).toBeGreaterThan(0); }); it('includes origin hex when bounds contain origin', () => { const hexes = getHexesInBounds( { minX: -10, minY: -10, maxX: 10, maxY: 10 }, size, ); const hasOrigin = hexes.some(h => h.q === 0 && h.r === 0); expect(hasOrigin).toBe(true); }); it('more hexes for larger area', () => { const small = getHexesInBounds( { minX: 0, minY: 0, maxX: 100, maxY: 100 }, size, ); const large = getHexesInBounds( { minX: 0, minY: 0, maxX: 500, maxY: 500 }, size, ); expect(large.length).toBeGreaterThan(small.length); }); it('smaller hex size yields more hexes', () => { const bounds = { minX: 0, minY: 0, maxX: 200, maxY: 200 }; const big = getHexesInBounds(bounds, 64); const small = getHexesInBounds(bounds, 16); expect(small.length).toBeGreaterThan(big.length); }); }); describe('hexAtPixel', () => { it('origin pixel maps to origin hex', () => { const coord = hexAtPixel({ x: 0, y: 0 }, 32); expect(coord.q).toBe(0); expect(coord.r).toBe(0); }); });