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 mockUndo = makeMockUndoRedo(appObjects);
    return {
        landmarkEnt,
        deleteLandmarkUC,
        repo,
        mockDispatcher,
        mockUndo,
    };
}
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, mockDispatcher } = makeTestRig();
        deleteLandmarkUC.deleteLandmark();
        expect(mockDispatcher.doDispatch).toHaveBeenCalled();
    });
    it("Registers an undo", () => {
        const { deleteLandmarkUC, mockUndo } = makeTestRig();
        deleteLandmarkUC.deleteLandmark();
        expect(mockUndo.submitAction).toHaveBeenCalled();
    });
});
//# sourceMappingURL=DeleteLandmarkUC.test.js.map