import { makeAppObjectRepo } from "@vived/core";
import { MockDispatcher } from "../Mocks/MockDispatcher";
import { makeStateIsCompleteUC, StateIsCompleteUC } from "./StateIsCompleteUC";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const appObject = appObjects.getOrCreate("Dispatcher");
    const mockDispatcher = new MockDispatcher(appObject);
    const uc = makeStateIsCompleteUC(appObject);
    return { uc, dispatcher: appObject, appObjects, mockDispatcher };
}
describe("Dispatch State Is Complete", () => {
    it("Gets the UC", () => {
        const { uc, appObjects } = makeTestRig();
        expect(StateIsCompleteUC.get(appObjects)).toEqual(uc);
    });
    it("Dispatches the correct type", () => {
        const { uc, mockDispatcher } = makeTestRig();
        uc.doDispatch();
        expect(mockDispatcher.formRequestAndDispatch).toHaveBeenCalledTimes(1);
        expect(mockDispatcher.formRequestAndDispatch.mock.calls[0][0]).toEqual("ON_STATE_COMPLETED");
    });
    it("Dispatches the correct version", () => {
        const { uc, mockDispatcher } = makeTestRig();
        uc.doDispatch();
        expect(mockDispatcher.formRequestAndDispatch).toHaveBeenCalledTimes(1);
        expect(mockDispatcher.formRequestAndDispatch.mock.calls[0][1]).toEqual(1);
    });
    it("Dispatches an undefined payload", () => {
        const { uc, mockDispatcher } = makeTestRig();
        uc.doDispatch();
        expect(mockDispatcher.formRequestAndDispatch).toHaveBeenCalledTimes(1);
        const payload = mockDispatcher.formRequestAndDispatch.mock.calls[0][2];
        expect(payload).toBeUndefined();
    });
});
//# sourceMappingURL=StateIsCompleteUC.test.js.map