import { makeAppObjectRepo, Vector3 } from "@vived/core";
import { makeSceneRootEntity } from "../../SceneRoot/Entities/SceneRootEntity";
import { makeCalloutEntity } from "../Entities/CalloutEntity";
import { CalloutLinePointsPM, makeCalloutLinePointsPM, } from "./CalloutLinePointsPM";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const appObj = appObjects.getOrCreate("appObj");
    const sceneRoot = makeSceneRootEntity(appObjects.getOrCreate("SceneRoot"));
    const ao = appObjects.getOrCreate("callout");
    const callout = makeCalloutEntity(ao);
    const pm = makeCalloutLinePointsPM(ao);
    return { appObj, appObjects, pm, callout, sceneRoot };
}
describe("Callout Line Presentation Manager", () => {
    it("Gets the PM", () => {
        const { appObjects, pm } = makeTestRig();
        expect(CalloutLinePointsPM.getById("callout", appObjects)).toEqual(pm);
    });
    it("Sets the last vm on construction", () => {
        const { pm } = makeTestRig();
        expect(pm.lastVM).not.toBeUndefined();
    });
    it("Returns true if the VMs are the same", () => {
        const { pm } = makeTestRig();
        const vm1 = [Vector3.Zero(), Vector3.One()];
        const vm2 = [Vector3.Zero(), Vector3.One()];
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(true);
    });
    it("Returns false if a vector is added", () => {
        const { pm } = makeTestRig();
        const vm1 = [Vector3.Zero(), Vector3.One()];
        const vm2 = [Vector3.Zero(), Vector3.One(), Vector3.Zero()];
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Returns false if a vector is removed", () => {
        const { pm } = makeTestRig();
        const vm1 = [Vector3.Zero(), Vector3.One()];
        const vm2 = [Vector3.Zero()];
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Returns false if a vector is changed", () => {
        const { pm } = makeTestRig();
        const vm1 = [Vector3.Zero(), Vector3.One()];
        const vm2 = [Vector3.Zero(), new Vector3(1, 2, 3)];
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Sets the first vector is the start position", () => {
        const { pm, callout } = makeTestRig();
        callout.rootTransform.localPosition = new Vector3(1, 2, 3);
        expect(pm.lastVM[0]).toEqual(new Vector3(1, 2, 3));
    });
    it("Sets the second vector is the start bump position", () => {
        const { pm, callout, sceneRoot } = makeTestRig();
        callout.rootTransform.localPosition = new Vector3(1, 2, 3);
        sceneRoot.scale = 0.01;
        const expected = new Vector3(1.0436, 2.08728, 3.17457);
        expect(Vector3.Close(pm.lastVM[1], expected)).toEqual(true);
    });
    it("Sets the third vector is the end bump position", () => {
        const { pm, callout, sceneRoot } = makeTestRig();
        callout.labelTransform.localPosition = new Vector3(4, 5, 6);
        sceneRoot.scale = 0.01;
        const expected = new Vector3(4.097, 5.097, 6.1455);
        expect(Vector3.Close(pm.lastVM[2], expected)).toEqual(true);
    });
    it("Sets the fourth vector is the end position", () => {
        const { pm, callout } = makeTestRig();
        callout.labelTransform.localPosition = new Vector3(4, 5, 6);
        expect(pm.lastVM[3]).toEqual(new Vector3(4, 5, 6));
    });
});
//# sourceMappingURL=CalloutLinePointsPM.test.js.map