import { makeAppObjectRepo } from "@vived/core";
import { makeTryHideWithPickUCMock } from "../Mocks/TryHideWithPickUCMock";
import { makeMouseInput, } from "../../MouseInput/Entities/MouseInput";
import { HideMC } from "./HideMC";
import { Vector2 } from "@vived/core";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const mockUC = makeTryHideWithPickUCMock(appObjects);
    const mouseInput = makeMouseInput(appObjects.getOrCreate("MouseInput"));
    const registerSpy = jest.spyOn(mouseInput, "registerController");
    const controller = new HideMC(appObjects.getOrCreate("Controller"));
    return { mouseInput, controller, mockUC, registerSpy };
}
describe("Mouse Click to hide controller", () => {
    it("Registers with the mouse input when constructed", () => {
        const { registerSpy, controller } = makeTestRig();
        expect(registerSpy).toHaveBeenCalledWith(controller);
    });
    it("Trigger the UC", () => {
        const { controller, mockUC } = makeTestRig();
        const evt = {
            position: new Vector2(2, 3),
            button: 0,
            event: new MouseEvent("buttonup"),
        };
        controller.onClick(evt);
        expect(mockUC.tryPixelPick).toHaveBeenCalledWith(new Vector2(2, 3));
    });
    it("Doesn't trigger the UC if allow returns false", () => {
        const { controller, mockUC } = makeTestRig();
        controller.allow = () => {
            return false;
        };
        const evt = {
            position: new Vector2(2, 3),
            button: 0,
            event: new MouseEvent("touchcancel"),
        };
        controller.onClick(evt);
        expect(mockUC.tryPixelPick).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=HideMC.test.js.map