import { makeAppObjectRepo } from "@vived/core";
import { AppDispatcher } from "../Entities/AppDispatcher";
import { makeMockDispatcher } from "../Mocks";
import { IsZSpaceAvailableUC, makeIsZSpaceAvailableUC, } from "./IsZSpaceAvailableUC";
class MockDispatcher extends AppDispatcher {
    constructor() {
        super(...arguments);
        this.dispatch = jest.fn();
        this.formRequestAndDispatch = jest.fn();
    }
}
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const dispatcher = appObjects.getOrCreate("Dispatcher");
    const mockDispatcher = makeMockDispatcher(appObjects);
    const uc = makeIsZSpaceAvailableUC(dispatcher);
    return { uc, dispatcher, appObjects, mockDispatcher };
}
describe("Dispatch State Change", () => {
    it("Gets the UC", () => {
        const { uc, appObjects } = makeTestRig();
        expect(IsZSpaceAvailableUC.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(uc.requestType);
    });
    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).toBeDefined();
    });
});
//# sourceMappingURL=IsZSpaceAvailableUC.test.js.map