import { describe, expect, it } from "vitest"; import { computeSelectionRing, SELECTION_RING_COLOR, SELECTION_RING_ID, } from "../src/map/selection-ring"; const planets = [ { number: 1, x: 10, y: 20 }, { number: 2, x: 30, y: 40 }, ]; describe("computeSelectionRing", () => { it("returns null when nothing is selected", () => { expect(computeSelectionRing(planets, null)).toBeNull(); }); it("returns null when the selected planet is absent from the report", () => { expect(computeSelectionRing(planets, 99)).toBeNull(); }); it("rings the selected planet at its coordinates", () => { const ring = computeSelectionRing(planets, 2); expect(ring).toMatchObject({ kind: "circle", id: SELECTION_RING_ID, x: 30, y: 40, hitSlopPx: 0, }); expect(ring?.style.strokeColor).toBe(SELECTION_RING_COLOR); // Sits outside the planet marker (radius 6 world units). expect(ring?.radius ?? 0).toBeGreaterThan(6); }); });