"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const TryHideWithPickUCMock_1 = require("../Mocks/TryHideWithPickUCMock");
const MouseInput_1 = require("../../MouseInput/Entities/MouseInput");
const HideMC_1 = require("./HideMC");
const core_2 = require("@vived/core");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const mockUC = (0, TryHideWithPickUCMock_1.makeTryHideWithPickUCMock)(appObjects);
    const mouseInput = (0, MouseInput_1.makeMouseInput)(appObjects.getOrCreate("MouseInput"));
    const registerSpy = jest.spyOn(mouseInput, "registerController");
    const controller = new HideMC_1.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 core_2.Vector2(2, 3),
            button: 0,
            event: new MouseEvent("buttonup"),
        };
        controller.onClick(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 = {
            position: new core_2.Vector2(2, 3),
            button: 0,
            event: new MouseEvent("touchcancel"),
        };
        controller.onClick(evt);
        expect(mockUC.tryPixelPick).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=HideMC.test.js.map