import { makeAppObjectRepo } from "@vived/core";
import { makeMockDispatchStateChange } from "../../Dispatcher/Mocks/MockDispatchStateChange";
import { makeMockUndoRedo } from "../../UndoRedo";
import { makeLandmarkRepoEntity } from "../Entities/LandmarkRepo";
import { makeDeleteLandmarkUC } from "./DeleteLandmarkUC";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const repoAO = appObjects.getOrCreate("LandmarkRepo");
    const repo = makeLandmarkRepoEntity(repoAO);
    const landmarkEnt = repo.createLandmark("aLandmark");
    const deleteLandmarkUC = makeDeleteLandmarkUC(landmarkEnt.appObject);
    const mockDispatcher = makeMockDispatchStateChange(appObjects);
    const doDispatchMock = jest.fn();
    mockDispatcher.doDispatch = doDispatchMock;
    const mockUndo = makeMockUndoRedo(appObjects);
    const submitActionMock = jest.fn();
    mockUndo.submitAction = submitActionMock;
    return {
        landmarkEnt,
        deleteLandmarkUC,
        repo,
        doDispatchMock,
        mockUndo,
        submitActionMock,
    };
}
describe("Delete Landmark UC", () => {
    it("Removed the landmark from the repo", () => {
        const { repo, deleteLandmarkUC } = makeTestRig();
        expect(repo.hasForAppObject("aLandmark")).toEqual(true);
        deleteLandmarkUC.deleteLandmark();
        expect(repo.hasForAppObject("aLandmark")).toEqual(false);
    });
    it("Dispatches a state change if not set to quietly", () => {
        const { deleteLandmarkUC, doDispatchMock } = makeTestRig();
        deleteLandmarkUC.deleteLandmark();
        expect(doDispatchMock).toHaveBeenCalled();
    });
    it("Registers an undo", () => {
        const { deleteLandmarkUC, submitActionMock } = makeTestRig();
        deleteLandmarkUC.deleteLandmark();
        expect(submitActionMock).toHaveBeenCalled();
    });
});
//# sourceMappingURL=DeleteLandmarkUC.test.js.map