"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const MockDispatchStateChange_1 = require("../../Dispatcher/Mocks/MockDispatchStateChange");
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 = new MockDispatchStateChange_1.MockDispatchStateChange(appAO);
    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,
        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, mockDispatcher } = makeTestRig();
        deleteAllCalloutsUC.deleteAllCallouts();
        expect(mockDispatcher.doDispatch).toHaveBeenCalled();
    });
    it("Creates an undo", () => {
        const { deleteAllCalloutsUC } = makeTestRig();
        deleteAllCalloutsUC.deleteAllCallouts();
        expect(DeleteAllCalloutsUndoRedo_1.DeleteAllCalloutsUndoRedo).toHaveBeenCalled();
    });
});
//# sourceMappingURL=DeleteAllCalloutsUC.test.js.map