"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const core_2 = require("@vived/core");
const SceneRoot_1 = require("../../SceneRoot");
const Entities_1 = require("../Entities");
const RestoreStoredViewUC_1 = require("./RestoreStoredViewUC");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const appObj = appObjects.getOrCreate(SceneRoot_1.SceneRootEntity.type);
    const sceneRoot = (0, SceneRoot_1.makeSceneRootEntity)(appObj);
    const storedView = (0, Entities_1.makeStoredView)(appObj);
    const uc = (0, RestoreStoredViewUC_1.makeRestoreStoredViewUC)(appObj);
    return {
        appObj,
        sceneRoot,
        storedView,
        uc,
        appObjects,
    };
}
describe("Restore Stored View UC", () => {
    it("Is added to the app object as a component", () => {
        const { appObj, uc } = makeTestRig();
        expect(appObj.hasComponent(uc.type)).toBeTruthy();
        expect(appObj.getComponent(uc.type)).toEqual(uc);
    });
    it("Restores the current view", () => {
        const { storedView, sceneRoot, uc } = makeTestRig();
        storedView.scale = 2;
        storedView.position = new core_2.Vector3(1, 2, 3);
        const rotQ = core_2.Quaternion.FromAngleAxis(new core_2.Vector3(1, 2, 3), core_2.Angle.FromDegrees(25));
        storedView.rotation = rotQ;
        storedView.hasStoredView = true;
        sceneRoot.scale = 3;
        sceneRoot.position = new core_2.Vector3(4, 5, 6);
        const rotQ2 = core_2.Quaternion.FromAngleAxis(new core_2.Vector3(4, 5, 6), core_2.Angle.FromDegrees(25));
        sceneRoot.rotation = rotQ2;
        const lerpMock = jest.fn();
        sceneRoot.transform.lerp = lerpMock;
        uc.restoreStoredView();
        const expectedDTO = {
            durationMS: 1000,
            ease: uc.ease,
            desiredPosition: new core_2.Vector3(1, 2, 3),
            desiredRotation: rotQ,
            desiredScale: new core_2.Vector3(2, 2, 2),
        };
        expect(lerpMock).toHaveBeenCalledWith(expectedDTO);
    });
    it("Gets the UC", () => {
        const { appObjects, uc } = makeTestRig();
        expect(RestoreStoredViewUC_1.RestoreStoredViewUC.get(appObjects)).toEqual(uc);
    });
});
//# sourceMappingURL=RestoreStoredViewUC.test.js.map