"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const core_2 = require("@vived/core");
const ZSpaceViewEntity_1 = require("./ZSpaceViewEntity");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const viewAO = appObjects.getOrCreate("viewAO");
    const zSpaceView = (0, ZSpaceViewEntity_1.makeZSpaceView)(viewAO, ZSpaceViewEntity_1.ZSpaceViewType.CENTER);
    const observer = jest.fn();
    zSpaceView.addChangeObserver(observer);
    return { zSpaceView, observer };
}
function mockUpdateDTO() {
    return {
        position: new core_2.Vector3(1, 2, 3),
        rotation: core_2.Quaternion.FromEuler(core_2.Angle.FromDegrees(10), core_2.Angle.FromDegrees(20), core_2.Angle.FromDegrees(30)),
        projectionMatrix: new core_2.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 core_2.Vector3(1, 2, 3));
    });
    it("Applies the rotation to the transform", () => {
        const { zSpaceView } = makeTestRig();
        const updateData = mockUpdateDTO();
        zSpaceView.update(updateData);
        expect(core_2.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(ZSpaceViewEntity_1.ZSpaceViewType.CENTER);
    });
});
//# sourceMappingURL=ZSpaceViewEntity.test.js.map