import { describe, expect, it } from "vitest";
import {
  effectiveSide,
  orientationAlongEdge,
  rotateSide,
} from "./orientation";

describe("orientation", () => {
  it("rotates sides clockwise", () => {
    expect(rotateSide("left", 90)).toBe("top");
    expect(rotateSide("left", 180)).toBe("right");
    expect(rotateSide("left", 270)).toBe("bottom");
  });

  it("applies Modelica rotate then flip", () => {
    expect(effectiveSide("left", 0, false, false)).toBe("left");
    expect(effectiveSide("left", 180, false, false)).toBe("right");
    expect(effectiveSide("left", 0, true, false)).toBe("right");
    expect(effectiveSide("top", 0, false, true)).toBe("bottom");
  });

  it("picks rotation along an edge", () => {
    expect(orientationAlongEdge({ x: 0, y: 0 }, { x: 100, y: 0 })).toBe(0);
    expect(orientationAlongEdge({ x: 100, y: 0 }, { x: 0, y: 0 })).toBe(180);
    expect(orientationAlongEdge({ x: 0, y: 0 }, { x: 0, y: 100 })).toBe(90);
    expect(orientationAlongEdge({ x: 0, y: 100 }, { x: 0, y: 0 })).toBe(270);
  });
});
