"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const core_2 = require("@vived/core");
const Dispatcher_1 = require("../../Dispatcher");
const Entities_1 = require("../Entities");
const ClearStoredViewUC_1 = require("./ClearStoredViewUC");
class MockDispatchStateChange extends Dispatcher_1.DispatchStateChangeUC {
    constructor() {
        super(...arguments);
        this.doDispatch = jest.fn();
        this.getStateAssets = jest.fn();
        this.validateState = jest.fn();
    }
}
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const appObj = appObjects.getOrCreate("SceneRoto");
    const storedView = (0, Entities_1.makeStoredView)(appObj);
    const mockDispatch = new MockDispatchStateChange(appObj, Dispatcher_1.DispatchStateChangeUC.type);
    const clearStoredViewUC = (0, ClearStoredViewUC_1.makeClearStoredViewUC)(appObj);
    const clearStoredView = clearStoredViewUC.clearStoredView;
    return {
        appObj,
        storedView,
        clearStoredViewUC,
        clearStoredView,
        mockDispatch,
        appObjects,
    };
}
describe("Clear Stored View UC", () => {
    it("Is added to the app object as a component", () => {
        const { appObj, clearStoredViewUC } = makeTestRig();
        expect(appObj.hasComponent(clearStoredViewUC.type)).toBeTruthy();
        expect(appObj.getComponent(clearStoredViewUC.type)).toEqual(clearStoredViewUC);
    });
    it("Clears the current view", () => {
        const { clearStoredView, storedView } = 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;
        clearStoredView();
        expect(storedView.position).toEqual(core_2.Vector3.Zero());
        expect(storedView.rotation).toEqual(core_2.Quaternion.Identity());
        expect(storedView.scale).toEqual(1);
        expect(storedView.hasStoredView).toEqual(false);
    });
    it("Dispatches a state change", () => {
        const { clearStoredView, storedView, mockDispatch } = 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;
        clearStoredView();
        expect(mockDispatch.doDispatch).toHaveBeenCalled();
    });
    it("Gets the UC", () => {
        const { appObjects, clearStoredViewUC } = makeTestRig();
        expect(ClearStoredViewUC_1.ClearStoredViewUC.get(appObjects)).toEqual(clearStoredViewUC);
    });
});
//# sourceMappingURL=ClearStoredViewUC.test.js.map