import { makeAppObjectRepo } from "@vived/core";
import { makeMockDispatchStateChange } from "../../Dispatcher";
import { makeCalloutRepoEntity } from "../Entities/CalloutRepo";
import { makeDeleteAllCalloutsUC } from "./DeleteAllCalloutsUC";
import { DeleteAllCalloutsUndoRedo } from "./DeleteAllCalloutsUndoRedo";
jest.mock("./DeleteAllCalloutsUndoRedo");
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const appAO = appObjects.getOrCreate("App");
    const mockDispatcher = makeMockDispatchStateChange(appObjects);
    const doDispatchMock = jest.fn();
    mockDispatcher.doDispatch = doDispatchMock;
    const deleteAllCalloutsUC = makeDeleteAllCalloutsUC(appAO);
    const repo1 = makeCalloutRepoEntity(appObjects.getOrCreate("parent1"));
    const repo2 = makeCalloutRepoEntity(appObjects.getOrCreate("parent2"));
    repo1.makeCallout();
    repo2.makeCallout();
    return {
        appAO,
        deleteAllCalloutsUC,
        mockDispatcher,
        doDispatchMock,
        repo1,
        repo2,
    };
}
describe("Delete All Callouts UC", () => {
    it("Deletes all callouts UC", () => {
        const { deleteAllCalloutsUC, repo1, repo2 } = makeTestRig();
        deleteAllCalloutsUC.deleteAllCallouts();
        expect(repo1.getAll().length).toEqual(0);
        expect(repo2.getAll().length).toEqual(0);
    });
    it("Dispatches state change", () => {
        const { deleteAllCalloutsUC, doDispatchMock } = makeTestRig();
        deleteAllCalloutsUC.deleteAllCallouts();
        expect(doDispatchMock).toHaveBeenCalled();
    });
    it("Creates an undo", () => {
        const { deleteAllCalloutsUC } = makeTestRig();
        deleteAllCalloutsUC.deleteAllCallouts();
        expect(DeleteAllCalloutsUndoRedo).toHaveBeenCalled();
    });
});
//# sourceMappingURL=DeleteAllCalloutsUC.test.js.map