"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const Babylon_1 = require("../../Babylon");
const Stylus_1 = require("../../Stylus");
const SelectAppObjectUCMock_1 = require("../Mocks/SelectAppObjectUCMock");
const StylusSelectAppObjectSC_1 = require("./StylusSelectAppObjectSC");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const zSpaceAO = appObjects.getOrCreate("stylus");
    const stylus = (0, Stylus_1.makeStylusEntity)(zSpaceAO);
    const mockRegisterController = jest.fn();
    stylus.registerController = mockRegisterController;
    const selectionAO = appObjects.getOrCreate("selection");
    const mockUC = new SelectAppObjectUCMock_1.SelectAppObjectUCMock(selectionAO);
    const mockPixelToSceneUC = (0, Babylon_1.makeMockPixelToSceneRayUC)(appObjects);
    const mockPixelToRay = jest.fn().mockReturnValue(core_1.ParametricLine.Forward());
    mockPixelToSceneUC.pixelToSceneRay = mockPixelToRay;
    const controller = new StylusSelectAppObjectSC_1.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(core_1.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