"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const MockDispatchStateChange_1 = require("../../Dispatcher/Mocks/MockDispatchStateChange");
const MockUndoRedo_1 = require("../../UndoRedo/Mocks/MockUndoRedo");
const CalloutEntity_1 = require("../Entities/CalloutEntity");
const SetCalloutSizeUndoRedo_1 = require("./SetCalloutSizeUndoRedo");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const ao = appObjects.getOrCreate("App");
    const mockUndo = new MockUndoRedo_1.MockUndoRedo(ao);
    const mockDispatcher = new MockDispatchStateChange_1.MockDispatchStateChange(ao);
    const callout = (0, CalloutEntity_1.makeCalloutEntity)(appObjects.getOrCreate("Landmark1"));
    return { callout, mockUndo, mockDispatcher, appObjects };
}
describe("Set Callout Undo Redo action", () => {
    it("Submits itself to the entity", () => {
        const { mockUndo, callout, appObjects } = makeTestRig();
        const undoData = {
            callout,
            undoSize: 0.8,
            redoSize: 1.1,
        };
        const action = new SetCalloutSizeUndoRedo_1.SetCalloutSizeUndoRedo(undoData, appObjects);
        expect(mockUndo.submitAction).toHaveBeenCalledWith(action);
    });
    it("Undo the size change", () => {
        const { appObjects, callout } = makeTestRig();
        callout.size = 1;
        const undoData = {
            callout,
            undoSize: 0.8,
            redoSize: 1.1,
        };
        const action = new SetCalloutSizeUndoRedo_1.SetCalloutSizeUndoRedo(undoData, appObjects);
        action.undoAction();
        expect(callout.size).toEqual(0.8);
    });
    it("Redo the size change", () => {
        const { appObjects, callout } = makeTestRig();
        callout.size = 1;
        const undoData = {
            callout,
            undoSize: 0.8,
            redoSize: 1.1,
        };
        const action = new SetCalloutSizeUndoRedo_1.SetCalloutSizeUndoRedo(undoData, appObjects);
        action.redoAction();
        expect(callout.size).toEqual(1.1);
    });
    it("Dispatches state changes for both the undo and redo action", () => {
        const { callout, appObjects, mockDispatcher } = makeTestRig();
        const undoData = {
            callout,
            undoSize: 0.8,
            redoSize: 1.1,
        };
        const action = new SetCalloutSizeUndoRedo_1.SetCalloutSizeUndoRedo(undoData, appObjects);
        action.undoAction();
        expect(mockDispatcher.doDispatch).toHaveBeenCalledTimes(1);
        action.redoAction();
        expect(mockDispatcher.doDispatch).toHaveBeenCalledTimes(2);
    });
});
//# sourceMappingURL=SetCalloutSizeUndoRedo.test.js.map