import { makeAppObjectRepo } from "@vived/core";
import { AppRenderingUC } from "../../BaseApp/UC/AppRenderingUC";
import { MockAppRenderingUC } from "../../BaseApp/Mocks/MockAppRenderingUC";
import { MockAppHandlerEntity } from "../Mocks/MockAppHandlerEntity";
import { makeStopAppUC } from "./StopAppUC";
function makeTestRig() {
    const appObjectRepo = makeAppObjectRepo();
    const handlerAO = appObjectRepo.getOrCreate("Handler");
    const mockRenderingUC = new MockAppRenderingUC(handlerAO);
    const mockAppHandler = new MockAppHandlerEntity(handlerAO);
    const stopApp = makeStopAppUC(handlerAO);
    return { mockAppHandler, stopApp, mockRenderingUC, appObjectRepo };
}
describe("On App Ready Base Handler", () => {
    it("Registers as a handler when constructed", () => {
        const { mockAppHandler, stopApp } = makeTestRig();
        expect(mockAppHandler.registerRequestHandler).toHaveBeenCalledWith(stopApp);
    });
    it("Triggers the action for v1", () => {
        const { stopApp } = makeTestRig();
        stopApp.action = jest.fn();
        stopApp.handleRequest(1);
        expect(stopApp.action).toHaveBeenCalled();
    });
    it("Throws for an unsupported version", () => {
        const { stopApp } = makeTestRig();
        expect(() => stopApp.handleRequest(-1)).toThrowError();
    });
    it("Calls stop rendering", () => {
        const { mockRenderingUC, stopApp, appObjectRepo } = makeTestRig();
        AppRenderingUC.get(appObjectRepo);
        stopApp.action();
        expect(mockRenderingUC.stopRendering).toHaveBeenCalled();
    });
});
//# sourceMappingURL=StopAppUC.test.js.map