import { makeAppObjectRepo } from "@vived/core";
import { makeMockDispatcher } from "../Mocks";
import { GoToPreviousStateUC, makeGoToPreviousStateUC, } from "./GoToPreviousStateUC";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const dispatcher = appObjects.getOrCreate("Dispatcher");
    const mockDispatcher = makeMockDispatcher(appObjects);
    const uc = makeGoToPreviousStateUC(dispatcher);
    return { uc, dispatcher, appObjects, mockDispatcher };
}
describe("Dispatch State Change", () => {
    it("Gets the UC", () => {
        const { uc, appObjects } = makeTestRig();
        expect(GoToPreviousStateUC.get(appObjects)).toEqual(uc);
    });
    it("Dispatch the correct type", () => {
        const { uc, mockDispatcher } = makeTestRig();
        uc.doDispatch();
        expect(mockDispatcher.formRequestAndDispatch).toHaveBeenCalledTimes(1);
        expect(mockDispatcher.formRequestAndDispatch.mock.calls[0][0]).toEqual(uc.requestType);
    });
    it("Dispatch 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=GoToPreviousStateUC.test.js.map