"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const Dispatcher_1 = require("../../Dispatcher");
const UndoRedo_1 = require("../../UndoRedo");
const LandmarkRepo_1 = require("../Entities/LandmarkRepo");
const DeleteAllLandmarksUC_1 = require("./DeleteAllLandmarksUC");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const mockDispatcher = (0, Dispatcher_1.makeMockDispatchStateChange)(appObjects);
    const doDispatchMock = jest.fn();
    mockDispatcher.doDispatch = doDispatchMock;
    const deleteAllLandmarksUC = (0, DeleteAllLandmarksUC_1.makeDeleteAllLandmarksUC)(appObjects.getOrCreate("Landmarks"));
    const repo1 = (0, LandmarkRepo_1.makeLandmarkRepoEntity)(appObjects.getOrCreate("parent1"));
    const repo2 = (0, LandmarkRepo_1.makeLandmarkRepoEntity)(appObjects.getOrCreate("parent2"));
    repo1.createLandmark("landmark1");
    repo2.createLandmark("landmark2");
    const undo = (0, UndoRedo_1.makeUndoRedoEntity)(appObjects.getOrCreate("Undo"));
    return {
        repo1,
        repo2,
        deleteAllLandmarksUC,
        doDispatchMock,
        undo,
    };
}
describe("Delete All Landmarks UC", () => {
    it("Deletes all Landmarks UC", () => {
        const { deleteAllLandmarksUC, repo1, repo2 } = makeTestRig();
        deleteAllLandmarksUC.deleteAllLandmarks();
        expect(repo1.getAll().length).toEqual(0);
        expect(repo2.getAll().length).toEqual(0);
    });
    it("Dispatches state change", () => {
        const { deleteAllLandmarksUC, doDispatchMock } = makeTestRig();
        deleteAllLandmarksUC.deleteAllLandmarks();
        expect(doDispatchMock).toHaveBeenCalled();
    });
    it("Is undoable and redoable", () => {
        const { deleteAllLandmarksUC, repo1, repo2, undo } = makeTestRig();
        deleteAllLandmarksUC.deleteAllLandmarks();
        expect(repo1.getAll().length).toEqual(0);
        expect(repo2.getAll().length).toEqual(0);
        undo.doUndo();
        expect(repo1.getAll().length).toEqual(1);
        expect(repo2.getAll().length).toEqual(1);
        undo.doRedo();
        expect(repo1.getAll().length).toEqual(0);
        expect(repo2.getAll().length).toEqual(0);
    });
});
//# sourceMappingURL=DeleteAllLandmarksUC.test.js.map