"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const Dispatcher_1 = require("../../Dispatcher");
const UndoRedoEntity_1 = require("../../UndoRedo/Entities/UndoRedoEntity");
const CalloutEntity_1 = require("../Entities/CalloutEntity");
const CalloutGlobals_1 = require("../Entities/CalloutGlobals");
const SetCalloutSizeUC_1 = require("./SetCalloutSizeUC");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const globalAO = appObjects.getOrCreate("calloutsGlobals");
    const calloutsGlobals = (0, CalloutGlobals_1.makeCalloutGlobals)(globalAO);
    const ao = appObjects.getOrCreate("calloutAO");
    const calloutEntity = (0, CalloutEntity_1.makeCalloutEntity)(ao);
    const uc = (0, SetCalloutSizeUC_1.makeSetCalloutSizeUC)(ao);
    const mockDispatcher = (0, Dispatcher_1.makeMockDispatchStateChange)(appObjects);
    const doDispatchMock = jest.fn();
    mockDispatcher.doDispatch = doDispatchMock;
    const undo = (0, UndoRedoEntity_1.makeUndoRedoEntity)(appObjects.getOrCreate("Undo"));
    return {
        calloutEntity,
        calloutsGlobals,
        uc,
        mockDispatcher,
        doDispatchMock,
        undo,
        appObjects,
    };
}
describe("Set Landmark Size UC", () => {
    it("Gets the UC", () => {
        const { appObjects, uc } = makeTestRig();
        expect(SetCalloutSizeUC_1.SetCalloutSizeUC.getById("calloutAO", appObjects)).toEqual(uc);
    });
    it("Updates the size with updateSize method", () => {
        const { calloutEntity, uc } = makeTestRig();
        uc.updateSize(0.5);
        expect(calloutEntity.size).toEqual(0.5);
    });
    it("Updates the size with submitSize method", () => {
        const { calloutEntity, uc } = makeTestRig();
        uc.updateSize(0.4);
        uc.submitSize(0.5);
        expect(calloutEntity.size).toEqual(0.5);
    });
    it("Sets the last size of calloutsGlobals with submitSize method", () => {
        const { calloutsGlobals, uc } = makeTestRig();
        uc.updateSize(0.4);
        uc.submitSize(0.8);
        expect(calloutsGlobals.lastSize).toEqual(0.8);
        uc.updateSize(0.4);
        uc.submitSize(0.7);
        expect(calloutsGlobals.lastSize).toEqual(0.7);
    });
    it("Dispatches a state change with submitSize method", () => {
        const { doDispatchMock, uc } = makeTestRig();
        uc.updateSize(0.5);
        uc.submitSize(0.6);
        expect(doDispatchMock).toHaveBeenCalled();
    });
    it("Is undo able and redo able", () => {
        const { undo, uc, calloutEntity } = makeTestRig();
        calloutEntity.size = 1;
        uc.updateSize(1.1);
        uc.submitSize(1.2);
        expect(calloutEntity.size).toEqual(1.2);
        undo.doUndo();
        expect(calloutEntity.size).toEqual(1);
        undo.doRedo();
        expect(calloutEntity.size).toEqual(1.2);
    });
});
//# sourceMappingURL=SetCalloutSizeUC.test.js.map