import { makeAppObjectRepo } from "@vived/core";
import { makeMockDispatchStateChange } from "../../Dispatcher/Mocks/MockDispatchStateChange";
import { makeCalloutRepoEntity } from "../Entities/CalloutRepo";
import { makeDeleteCalloutUC } from "./DeleteCallout";
import { DeleteCalloutUndoRedo } from "./DeleteCalloutUndoRedo";
jest.mock("./DeleteCalloutUndoRedo");
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const mockDispatchStateChange = makeMockDispatchStateChange(appObjects);
    const doDispatchMock = jest.fn();
    mockDispatchStateChange.doDispatch = doDispatchMock;
    const repoObj = appObjects.getOrCreate("repoObj");
    const repo = makeCalloutRepoEntity(repoObj);
    const callout = repo.makeCallout("calloutID");
    const uc = 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).toHaveBeenCalled();
    });
});
//# sourceMappingURL=DeleteCallout.test.js.map