import { makeAppObjectRepo } from "@vived/core";
import { MockDispatchStateChange } from "../../Dispatcher/Mocks/MockDispatchStateChange";
import { MockUndoRedo } from "../../UndoRedo/Mocks/MockUndoRedo";
import { makeLandmarkEntity } from "../Entities/LandmarkEntity";
import { SetLandmarkSizeUndoRedo, } from "./SetLandmarkSizeUndoRedo";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const ao = appObjects.getOrCreate("App");
    const mockUndo = new MockUndoRedo(ao);
    const mockDispatcher = new MockDispatchStateChange(ao);
    const landmark = makeLandmarkEntity(appObjects.getOrCreate("Landmark1"));
    return { landmark, mockUndo, mockDispatcher, appObjects };
}
describe("SetLandmarkSize Undo Redo action", () => {
    it("Submits itself to the entity", () => {
        const { mockUndo, landmark, appObjects } = makeTestRig();
        const undoData = {
            landmark,
            undoSize: 5,
            redoSize: 3,
        };
        const action = new SetLandmarkSizeUndoRedo(undoData, appObjects);
        expect(mockUndo.submitAction).toHaveBeenCalledWith(action);
    });
    it("Undo the size change", () => {
        const { appObjects, landmark } = makeTestRig();
        landmark.size = 1;
        const undoData = {
            landmark,
            undoSize: 5,
            redoSize: 3,
        };
        const action = new SetLandmarkSizeUndoRedo(undoData, appObjects);
        action.undoAction();
        expect(landmark.size).toEqual(5);
    });
    it("Redo the size change", () => {
        const { appObjects, landmark } = makeTestRig();
        landmark.size = 1;
        const undoData = {
            landmark,
            undoSize: 5,
            redoSize: 3,
        };
        const action = new SetLandmarkSizeUndoRedo(undoData, appObjects);
        action.redoAction();
        expect(landmark.size).toEqual(3);
    });
    it("Dispatches state changes for both the undo and redo action", () => {
        const { landmark, appObjects, mockDispatcher } = makeTestRig();
        const undoData = {
            landmark,
            undoSize: 5,
            redoSize: 3,
        };
        const action = new SetLandmarkSizeUndoRedo(undoData, appObjects);
        action.undoAction();
        expect(mockDispatcher.doDispatch).toHaveBeenCalledTimes(1);
        action.redoAction();
        expect(mockDispatcher.doDispatch).toHaveBeenCalledTimes(2);
    });
});
//# sourceMappingURL=SetLandmarkSizeUndoRedo.test.js.map