import { makeAppObjectRepo } from "@vived/core";
import { Angle, Matrix, Quaternion, Vector3 } from "@vived/core";
import { makeZSpaceView, ZSpaceViewType } from "./ZSpaceViewEntity";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const viewAO = appObjects.getOrCreate("viewAO");
    const zSpaceView = makeZSpaceView(viewAO, ZSpaceViewType.CENTER);
    const observer = jest.fn();
    zSpaceView.addChangeObserver(observer);
    return { zSpaceView, observer };
}
function mockUpdateDTO() {
    return {
        position: new Vector3(1, 2, 3),
        rotation: Quaternion.FromEuler(Angle.FromDegrees(10), Angle.FromDegrees(20), Angle.FromDegrees(30)),
        projectionMatrix: new Matrix([
            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
        ]),
    };
}
describe("ZSpace View", () => {
    it("Notifies when an update is submitted", () => {
        const { zSpaceView, observer } = makeTestRig();
        const updateData = mockUpdateDTO();
        zSpaceView.update(updateData);
        expect(observer).toHaveBeenCalled();
    });
    it("Applies the position to the transform", () => {
        const { zSpaceView } = makeTestRig();
        const updateData = mockUpdateDTO();
        zSpaceView.update(updateData);
        expect(zSpaceView.transform.localPosition).toEqual(new Vector3(1, 2, 3));
    });
    it("Applies the rotation to the transform", () => {
        const { zSpaceView } = makeTestRig();
        const updateData = mockUpdateDTO();
        zSpaceView.update(updateData);
        expect(Quaternion.Close(zSpaceView.transform.localRotation, updateData.rotation)).toEqual(true);
    });
    it("Stores the projection matrix", () => {
        const { zSpaceView } = makeTestRig();
        const updateData = mockUpdateDTO();
        zSpaceView.update(updateData);
        expect(zSpaceView.projectionMatrix).toEqual(updateData.projectionMatrix);
    });
    it("Sets the View Type", () => {
        const { zSpaceView } = makeTestRig();
        expect(zSpaceView.viewType).toEqual(ZSpaceViewType.CENTER);
    });
});
//# sourceMappingURL=ZSpaceViewEntity.test.js.map