"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const MockDispatchStateChange_1 = require("../../Dispatcher/Mocks/MockDispatchStateChange");
const UndoRedo_1 = require("../../UndoRedo");
const LandmarkRepo_1 = require("../Entities/LandmarkRepo");
const DeleteLandmarkUC_1 = require("./DeleteLandmarkUC");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const repoAO = appObjects.getOrCreate("LandmarkRepo");
    const repo = (0, LandmarkRepo_1.makeLandmarkRepoEntity)(repoAO);
    const landmarkEnt = repo.createLandmark("aLandmark");
    const deleteLandmarkUC = (0, DeleteLandmarkUC_1.makeDeleteLandmarkUC)(landmarkEnt.appObject);
    const mockDispatcher = (0, MockDispatchStateChange_1.makeMockDispatchStateChange)(appObjects);
    const doDispatchMock = jest.fn();
    mockDispatcher.doDispatch = doDispatchMock;
    const mockUndo = (0, UndoRedo_1.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