import { makeAppObjectRepo } from "@vived/core";
import { Angle, Quaternion, Vector3 } from "@vived/core";
import { makeSceneRootEntity, SceneRootEntity } from "../../SceneRoot";
import { makeStoredView } from "../Entities";
import { RestoreStoredViewUC, makeRestoreStoredViewUC, } from "./RestoreStoredViewUC";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const appObj = appObjects.getOrCreate(SceneRootEntity.type);
    const sceneRoot = makeSceneRootEntity(appObj);
    const storedView = makeStoredView(appObj);
    const uc = 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 Vector3(1, 2, 3);
        const rotQ = Quaternion.FromAngleAxis(new Vector3(1, 2, 3), Angle.FromDegrees(25));
        storedView.rotation = rotQ;
        storedView.hasStoredView = true;
        sceneRoot.scale = 3;
        sceneRoot.position = new Vector3(4, 5, 6);
        const rotQ2 = Quaternion.FromAngleAxis(new Vector3(4, 5, 6), 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 Vector3(1, 2, 3),
            desiredRotation: rotQ,
            desiredScale: new Vector3(2, 2, 2),
        };
        expect(lerpMock).toHaveBeenCalledWith(expectedDTO);
    });
    it("Gets the UC", () => {
        const { appObjects, uc } = makeTestRig();
        expect(RestoreStoredViewUC.get(appObjects)).toEqual(uc);
    });
});
//# sourceMappingURL=RestoreStoredViewUC.test.js.map