import { describe, expect, it } from "vitest";
import { MOCK_POLYGON_TASHKENT } from "@/lib/fixtures/dashboard-mockup-personas";
import { formatCoordinates, polygonToSvgPath, projectPolygonPoint } from "@/components/agnet/identity/polygon-svg";

describe("polygon-svg", () => {
  it("projects polygon to SVG path", () => {
    const { path, viewBox, bounds } = polygonToSvgPath(MOCK_POLYGON_TASHKENT);
    expect(viewBox).toBe("0 0 400 280");
    expect(path.startsWith("M ")).toBe(true);
    expect(path.endsWith(" Z")).toBe(true);
    expect(bounds).not.toBeNull();
  });

  it("formats coordinates with hemisphere labels", () => {
    expect(formatCoordinates(41.3155, 69.282)).toBe("41.3155° N, 69.2820° E");
  });

  it("projects a point within viewBox bounds", () => {
    const { bounds } = polygonToSvgPath(MOCK_POLYGON_TASHKENT);
    const { x, y } = projectPolygonPoint(69.282, 41.3155, bounds!);
    expect(x).toBeGreaterThan(0);
    expect(x).toBeLessThan(400);
    expect(y).toBeGreaterThan(0);
    expect(y).toBeLessThan(280);
  });
});
