import { makeAppObjectRepo, ParametricLine } from "@vived/core";
import { makeStylusEntity } from "../../Stylus";
import { HoverAppObjectUCMock } from "../Mocks/HoverAppObjectUCMock";
import { StylusHoverOnAppObjectSC } from "./StylusHoverOnAppObjectSC";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const ao = appObjects.getOrCreate("stylus");
    const stylus = makeStylusEntity(ao);
    const mockRegisterController = jest.fn();
    stylus.registerController = mockRegisterController;
    const selectionAO = appObjects.getOrCreate("selection");
    const mockUC = new HoverAppObjectUCMock(selectionAO);
    const controller = new 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(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(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(anotherAppObj);
        expect(mockRegisterController).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=StylusHoverOnAppObjectSC.test.js.map