import { makeAppObjectRepo } from "@vived/core";
import { Vector2 } from "@vived/core";
import { makeTouchInput } from "../../TouchController";
import { mockTouchInputEvent } from "../../TouchController/Mock/mockTouchInputEvent";
import { makeTryHideWithPickUCMock } from "../Mocks/TryHideWithPickUCMock";
import { HideTC } from "./HideTC";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const mockUC = makeTryHideWithPickUCMock(appObjects);
    const touchInput = makeTouchInput(appObjects.getOrCreate("MouseInput"));
    const registerSpy = jest.spyOn(touchInput, "registerController");
    const controller = new HideTC(appObjects.getOrCreate("Controller"));
    return { touchInput, controller, mockUC, registerSpy };
}
describe("Tap 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 = mockTouchInputEvent([new Vector2(2, 3)]);
        controller.onTap(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 = mockTouchInputEvent([new Vector2(2, 3)]);
        controller.onTap(evt);
        expect(mockUC.tryPixelPick).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=HideTC.test.js.map