"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 DeleteCallout_1 = require("./DeleteCallout");
const DeleteCalloutUndoRedo_1 = require("./DeleteCalloutUndoRedo");
jest.mock("./DeleteCalloutUndoRedo");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const mockDispatchStateChange = (0, MockDispatchStateChange_1.makeMockDispatchStateChange)(appObjects);
    const doDispatchMock = jest.fn();
    mockDispatchStateChange.doDispatch = doDispatchMock;
    const repoObj = appObjects.getOrCreate("repoObj");
    const repo = (0, CalloutRepo_1.makeCalloutRepoEntity)(repoObj);
    const callout = repo.makeCallout("calloutID");
    const uc = (0, DeleteCallout_1.makeDeleteCalloutUC)(callout.appObject);
    return {
        appObjects,
        repoObj,
        repo,
        uc,
        mockDispatchStateChange,
        doDispatchMock,
    };
}
describe("Delete Callout UC", () => {
    it("Deletes the callout from the repo", () => {
        const { repo, uc } = makeTestRig();
        const spy = jest.spyOn(repo, "deleteCallout");
        uc.delete();
        expect(spy).toHaveBeenCalledWith("calloutID");
    });
    it("Dispatches a state change", () => {
        const { doDispatchMock, uc } = makeTestRig();
        uc.delete();
        expect(doDispatchMock).toHaveBeenCalled();
    });
    it("Creates an undo", () => {
        const { uc } = makeTestRig();
        uc.delete();
        expect(DeleteCalloutUndoRedo_1.DeleteCalloutUndoRedo).toHaveBeenCalled();
    });
});
//# sourceMappingURL=DeleteCallout.test.js.map