import test from "node:test"; import assert from "node:assert/strict"; import { findPath } from "../src/navigation/astar.js"; test("A* walks around an impassable tile", () => { const blocked = new Set(["1,0"]); const path = findPath(0, 0, 2, 0, (x, y) => !blocked.has(`${x},${y}`), -4, -4, 4, 4); assert.ok(path.length > 0); assert.deepEqual(path.at(-1), { x: 2, y: 0 }); assert.ok(!path.some((step) => step.x === 1 && step.y === 0)); }); test("A* returns empty when the goal is blocked", () => { const path = findPath(0, 0, 1, 0, (x, y) => x === 0 && y === 0, -2, -2, 2, 2); assert.deepEqual(path, []); });