"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const Mocks_1 = require("../Mocks");
const GoToPreviousStateUC_1 = require("./GoToPreviousStateUC");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const dispatcher = appObjects.getOrCreate("Dispatcher");
    const mockDispatcher = (0, Mocks_1.makeMockDispatcher)(appObjects);
    const uc = (0, GoToPreviousStateUC_1.makeGoToPreviousStateUC)(dispatcher);
    return { uc, dispatcher, appObjects, mockDispatcher };
}
describe("Dispatch State Change", () => {
    it("Gets the UC", () => {
        const { uc, appObjects } = makeTestRig();
        expect(GoToPreviousStateUC_1.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