fix(test): correct same-cell astar assertion to match code behavior

The test expected [] for same-cell targets, but the code correctly
returns [{ x: ex, y: ey }] so the movement layer can make the final
fine-grained adjustment to the exact pixel.

Made-with: Cursor
This commit is contained in:
iamlukethedev
2026-03-27 13:19:02 -05:00
committed by iamlukethedev
parent 450f4873f6
commit fcecece1c3
+6 -5
View File
@@ -150,9 +150,10 @@ describe("astar — failure state returns empty array (Issue #3 fix)", () => {
}); });
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
it("returns [] when start snaps to the same free cell as end (already arrived)", () => { it("returns a single-waypoint path when start and end snap to the same free cell", () => {
// When start and end map to the exact same grid cell astar returns []. // When start and end map to the same grid cell the destination is still
// The agent is already at the target — no movement needed. // reachable — astar returns the exact target pixel so the movement layer
// can make the final fine-grained adjustment.
const grid = buildNavGrid([]); const grid = buildNavGrid([]);
// Pick pixel coords that both land in grid cell (4, 4). // Pick pixel coords that both land in grid cell (4, 4).
@@ -164,8 +165,8 @@ describe("astar — failure state returns empty array (Issue #3 fix)", () => {
const path = astar(sx, sy, ex, ey, grid); const path = astar(sx, sy, ex, ey, grid);
// Same cell — no waypoints needed. // Same cell — return exact target so the agent can settle onto it.
expect(path).toEqual([]); expect(path).toEqual([{ x: ex, y: ey }]);
}); });
}); });