"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const Dispatcher_1 = require("../../Dispatcher");
const CalloutRepo_1 = require("../Entities/CalloutRepo");
const DeleteAllCalloutsUC_1 = require("./DeleteAllCalloutsUC");
const DeleteAllCalloutsUndoRedo_1 = require("./DeleteAllCalloutsUndoRedo");
jest.mock("./DeleteAllCalloutsUndoRedo");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const appAO = appObjects.getOrCreate("App");
    const mockDispatcher = (0, Dispatcher_1.makeMockDispatchStateChange)(appObjects);
    const doDispatchMock = jest.fn();
    mockDispatcher.doDispatch = doDispatchMock;
    const deleteAllCalloutsUC = (0, DeleteAllCalloutsUC_1.makeDeleteAllCalloutsUC)(appAO);
    const repo1 = (0, CalloutRepo_1.makeCalloutRepoEntity)(appObjects.getOrCreate("parent1"));
    const repo2 = (0, CalloutRepo_1.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_1.DeleteAllCalloutsUndoRedo).toHaveBeenCalled();
    });
});
//# sourceMappingURL=DeleteAllCalloutsUC.test.js.map