import { makeAppObjectRepo } from "@vived/core";
import { ParametricLine, Vector3 } from "@vived/core";
import { makeStylusEntity } from "../../Stylus/Entity/StylusEntity";
import { makeTrySubmitObjectPickUCMock } from "../Mocks/TrySubmitObjectPickUCMock";
import { StylusObjectPickSC } from "./StylusObjectPickSC";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const stylus = makeStylusEntity(appObjects.getOrCreate("Input"));
    const registerSpy = jest.spyOn(stylus, "registerController");
    const trySubmit = makeTrySubmitObjectPickUCMock(appObjects).tryWithRay;
    const controller = new StylusObjectPickSC(appObjects.getOrCreate("AO"));
    return { controller, registerSpy, trySubmit, stylus };
}
describe("Mouse Object Pick Controller", () => {
    it("Registers with the input when constructed", () => {
        const { registerSpy, controller } = makeTestRig();
        expect(registerSpy).toHaveBeenCalledWith(controller);
    });
    it("Doesn't trigger the UC when the click is not button 0", () => {
        const { controller, trySubmit } = makeTestRig();
        controller.onButtonClick(1);
        expect(trySubmit).not.toHaveBeenCalled();
    });
    it("Trigger the UC when the click is button 0", () => {
        const { controller, trySubmit } = makeTestRig();
        controller.onButtonClick(0);
        expect(trySubmit).toHaveBeenCalled();
    });
    it("Sends the", () => {
        const { controller, trySubmit, stylus } = makeTestRig();
        const ray = ParametricLine.FromTwoPoint(new Vector3(1, 2, 3), new Vector3(4, 5, 6));
        jest.spyOn(stylus, "pickRay", "get").mockReturnValue(ray);
        controller.onButtonClick(0);
        expect(trySubmit).toHaveBeenCalledWith(ray);
    });
});
//# sourceMappingURL=StylusObjectPickSC.test.js.map