import { describe, expect, it, vi } from "vitest"; import { isMobAggroRangeVisible, MOB_AGGRO_RANGE_VISIBILITY_DISTANCE, } from "./mobAggroRangeVisibility"; describe("mob aggro range visibility", () => { it("shows an in-range mob only when the player has line of sight", () => { const visible = vi.fn(() => true); const blocked = vi.fn(() => false); expect(isMobAggroRangeVisible([0, 0, 0], [20, 0, 0], visible)).toBe(true); expect(isMobAggroRangeVisible([0, 0, 0], [20, 0, 0], blocked)).toBe(false); expect(visible).toHaveBeenCalledWith([0, 0, 0], [20, 0, 0]); expect(blocked).toHaveBeenCalledWith([0, 0, 0], [20, 0, 0]); }); it("hides distant mobs without performing a line-of-sight query", () => { const hasLineOfSight = vi.fn(() => true); expect(isMobAggroRangeVisible( [0, 0, 0], [MOB_AGGRO_RANGE_VISIBILITY_DISTANCE + 0.01, 0, 0], hasLineOfSight, )).toBe(false); expect(hasLineOfSight).not.toHaveBeenCalled(); }); it("includes mobs exactly on the visibility boundary", () => { expect(isMobAggroRangeVisible( [0, 0, 0], [0, 0, MOB_AGGRO_RANGE_VISIBILITY_DISTANCE], () => true, )).toBe(true); }); });