import { makeAppObjectRepo } from "@vived/core";
import { makeBabylonEntity } from "../../Babylon";
import { MockAppHandlerEntity } from "../Mocks/MockAppHandlerEntity";
import { makeShowBabylonInspectorUC } from "./ShowBabylonInspectorUC";
function makeTestRig() {
    const appObjectRepo = makeAppObjectRepo();
    const handlerAO = appObjectRepo.getOrCreate("Handler");
    const mockAppHandler = new MockAppHandlerEntity(handlerAO);
    const babylonEntity = makeBabylonEntity(handlerAO);
    const showBabylon = makeShowBabylonInspectorUC(handlerAO);
    return { mockAppHandler, showBabylon, babylonEntity };
}
describe("Show babylon Base Handler", () => {
    it("Registers as a handler when constructed", () => {
        const { mockAppHandler, showBabylon } = makeTestRig();
        expect(mockAppHandler.registerRequestHandler).toHaveBeenCalledWith(showBabylon);
    });
    it("Triggers the action for v1 if the payload is true", () => {
        const { showBabylon } = makeTestRig();
        showBabylon.action = jest.fn();
        showBabylon.handleRequest(1, { showBabylonInspector: true });
        expect(showBabylon.action).toHaveBeenCalledWith(true);
    });
    it("Triggers the action for v1 if the payload is false", () => {
        const { showBabylon } = makeTestRig();
        showBabylon.action = jest.fn();
        showBabylon.handleRequest(1, { showBabylonInspector: false });
        expect(showBabylon.action).toHaveBeenCalledWith(false);
    });
    it("Throws for an bungled payload", () => {
        const { showBabylon } = makeTestRig();
        expect(() => showBabylon.handleRequest(1, { foo: "bar" })).toThrowError();
    });
    it("Throws for an unsupported version", () => {
        const { showBabylon } = makeTestRig();
        expect(() => showBabylon.handleRequest(-1, { showBabylonInspector: false })).toThrowError();
    });
    it("Sets babylon inspector shown", () => {
        const { babylonEntity, showBabylon } = makeTestRig();
        expect(babylonEntity.showInspector).toEqual(false);
        showBabylon.action(true);
        expect(babylonEntity.showInspector).toEqual(true);
        showBabylon.action(false);
        expect(babylonEntity.showInspector).toEqual(false);
    });
});
//# sourceMappingURL=ShowBabylonInspectorUC.test.js.map