"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const AppRenderingUC_1 = require("../../BaseApp/UC/AppRenderingUC");
const MockAppRenderingUC_1 = require("../../BaseApp/Mocks/MockAppRenderingUC");
const MockAppHandlerEntity_1 = require("../Mocks/MockAppHandlerEntity");
const StopAppUC_1 = require("./StopAppUC");
function makeTestRig() {
    const appObjectRepo = (0, core_1.makeAppObjectRepo)();
    const handlerAO = appObjectRepo.getOrCreate("Handler");
    const mockRenderingUC = new MockAppRenderingUC_1.MockAppRenderingUC(handlerAO);
    const mockAppHandler = new MockAppHandlerEntity_1.MockAppHandlerEntity(handlerAO);
    const stopApp = (0, StopAppUC_1.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_1.AppRenderingUC.get(appObjectRepo);
        stopApp.action();
        expect(mockRenderingUC.stopRendering).toHaveBeenCalled();
    });
});
//# sourceMappingURL=StopAppUC.test.js.map