import { makeAppObjectRepo, ParametricLine } from "@vived/core";
import { makeMockPixelToSceneRayUC } from "../../Babylon";
import { makeStylusEntity } from "../../Stylus";
import { SelectAppObjectUCMock } from "../Mocks/SelectAppObjectUCMock";
import { StylusSelectAppObjectSC } from "./StylusSelectAppObjectSC";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const zSpaceAO = appObjects.getOrCreate("stylus");
    const stylus = makeStylusEntity(zSpaceAO);
    const mockRegisterController = jest.fn();
    stylus.registerController = mockRegisterController;
    const selectionAO = appObjects.getOrCreate("selection");
    const mockUC = new SelectAppObjectUCMock(selectionAO);
    const mockPixelToSceneUC = makeMockPixelToSceneRayUC(appObjects);
    const mockPixelToRay = jest.fn().mockReturnValue(ParametricLine.Forward());
    mockPixelToSceneUC.pixelToSceneRay = mockPixelToRay;
    const controller = new StylusSelectAppObjectSC(selectionAO);
    const mockAllow = jest.fn();
    mockAllow.mockReturnValue(true);
    controller.allow = mockAllow;
    return {
        appObjects,
        stylus,
        controller,
        mockUC,
        mockAllow,
        mockRegisterController,
    };
}
describe("Select Scene Object Stylus Controller", () => {
    it("Sends a ray to the UC on select", () => {
        const { mockUC, controller } = makeTestRig();
        const button = 0;
        controller.onButtonClick(button);
        expect(mockUC.trySelectAppObject).toHaveBeenCalledWith(ParametricLine.Forward());
    });
    it("Does not send a ray to the UC on click if not allowed", () => {
        const { controller, mockAllow, mockUC } = makeTestRig();
        const button = 0;
        mockAllow.mockReturnValue(false);
        controller.onButtonClick(button);
        expect(mockUC.trySelectAppObject).not.toHaveBeenCalled();
    });
    it("Registers itself", () => {
        const { controller, mockRegisterController } = makeTestRig();
        expect(mockRegisterController).toHaveBeenCalledWith(controller);
    });
});
//# sourceMappingURL=StylusSelectAppObjectSC.test.js.map