import { makeAppObjectRepo } from "@vived/core";
import { Vector2 } from "@vived/core";
import { MockMouseInput } from "../../MouseInput/Mocks/MockMouseInput";
import { BumpSceneRootScaleAboutPixelPointUC } from "../UC/BumpSceneRootScaleAboutPixelPoint";
import { MouseRoll } from "./MouseRoll";
class MockUC extends BumpSceneRootScaleAboutPixelPointUC {
    constructor() {
        super(...arguments);
        this.allow = jest.fn();
        this.bump = jest.fn();
    }
}
export function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const appAO = appObjects.getOrCreate("AO");
    const mockBump = new MockUC(appAO, BumpSceneRootScaleAboutPixelPointUC.type);
    const mockMouseInput = new MockMouseInput(appAO);
    const rollController = new MouseRoll(appAO);
    return { mockMouseInput, rollController, mockBump };
}
describe("Mouse Dolly Controller", () => {
    it("Bumps in if the roll is negative", () => {
        const { rollController, mockBump } = makeTestRig();
        const evt = {
            position: new Vector2(2, 3),
            event: new WheelEvent("buttondown", { deltaY: -25 }),
        };
        rollController.onWheel(evt);
        expect(mockBump.bump).toHaveBeenCalledWith("IN", new Vector2(2, 3));
    });
    it("Bumps out if the roll is positive", () => {
        const { rollController, mockBump } = makeTestRig();
        const evt = {
            position: new Vector2(2, 3),
            event: new WheelEvent("buttondown", { deltaY: 25 }),
        };
        rollController.onWheel(evt);
        expect(mockBump.bump).toHaveBeenCalledWith("OUT", new Vector2(2, 3));
    });
    it("Does not bump if allow returns false", () => {
        const { rollController, mockBump } = makeTestRig();
        const evt = {
            position: new Vector2(2, 3),
            event: new WheelEvent("buttondown", { deltaY: 25 }),
        };
        rollController.allow = () => {
            return false;
        };
        rollController.onWheel(evt);
        expect(mockBump.bump).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=MouseRoll.test.js.map