"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const core_2 = require("@vived/core");
const TouchController_1 = require("../../TouchController");
const mockTouchInputEvent_1 = require("../../TouchController/Mock/mockTouchInputEvent");
const TryHideWithPickUCMock_1 = require("../Mocks/TryHideWithPickUCMock");
const HideTC_1 = require("./HideTC");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const mockUC = (0, TryHideWithPickUCMock_1.makeTryHideWithPickUCMock)(appObjects);
    const touchInput = (0, TouchController_1.makeTouchInput)(appObjects.getOrCreate("MouseInput"));
    const registerSpy = jest.spyOn(touchInput, "registerController");
    const controller = new HideTC_1.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 = (0, mockTouchInputEvent_1.mockTouchInputEvent)([new core_2.Vector2(2, 3)]);
        controller.onTap(evt);
        expect(mockUC.tryPixelPick).toHaveBeenCalledWith(new core_2.Vector2(2, 3));
    });
    it("Doesn't trigger the UC if allow returns false", () => {
        const { controller, mockUC } = makeTestRig();
        controller.allow = () => {
            return false;
        };
        const evt = (0, mockTouchInputEvent_1.mockTouchInputEvent)([new core_2.Vector2(2, 3)]);
        controller.onTap(evt);
        expect(mockUC.tryPixelPick).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=HideTC.test.js.map