"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const Stylus_1 = require("../../Stylus");
const HoverAppObjectUCMock_1 = require("../Mocks/HoverAppObjectUCMock");
const StylusHoverOnAppObjectSC_1 = require("./StylusHoverOnAppObjectSC");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const ao = appObjects.getOrCreate("stylus");
    const stylus = (0, Stylus_1.makeStylusEntity)(ao);
    const mockRegisterController = jest.fn();
    stylus.registerController = mockRegisterController;
    const selectionAO = appObjects.getOrCreate("selection");
    const mockUC = new HoverAppObjectUCMock_1.HoverAppObjectUCMock(selectionAO);
    const controller = new StylusHoverOnAppObjectSC_1.StylusHoverOnAppObjectSC(selectionAO);
    const mockAllow = jest.fn();
    mockAllow.mockReturnValue(true);
    controller.allow = mockAllow;
    return {
        appObjects,
        controller,
        mockUC,
        mockAllow,
        mockRegisterController,
    };
}
describe("Hover Scene Object Stylus Controller", () => {
    it("Sends a ray to the UC on move", () => {
        const { mockUC, controller } = makeTestRig();
        controller.onStylusMove();
        expect(mockUC.tryHoverAppObject).toHaveBeenCalledWith(core_1.ParametricLine.Forward());
    });
    it("Does not send a ray to the UC on move if not allowed", () => {
        const { controller, mockAllow, mockUC } = makeTestRig();
        mockAllow.mockReturnValue(false);
        controller.onStylusMove();
        expect(mockUC.tryHoverAppObject).not.toHaveBeenCalled();
    });
    it("Warns if it is added to an app object that does not have a UC", () => {
        const { appObjects } = makeTestRig();
        const anotherAppObj = appObjects.getOrCreate("newAppObj");
        console.warn = jest.fn();
        new StylusHoverOnAppObjectSC_1.StylusHoverOnAppObjectSC(anotherAppObj);
        expect(console.warn).toHaveBeenCalled();
    });
    it("Does not register itself if the object does not have a UC", () => {
        const { appObjects, mockRegisterController } = makeTestRig();
        const anotherAppObj = appObjects.getOrCreate("newAppObj");
        console.warn = jest.fn();
        mockRegisterController.mockClear();
        new StylusHoverOnAppObjectSC_1.StylusHoverOnAppObjectSC(anotherAppObj);
        expect(mockRegisterController).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=StylusHoverOnAppObjectSC.test.js.map