import { makeAppObjectRepo } from "@vived/core";
import { makeStylusEntity } from "../../../Stylus";
import { MockRayPanScaleTransformUC } from "../../Mocks/MockRayPanScaleTransformUC";
import { PanScaleTransformSC } from "./PanScaleTransformSC";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const stylus = makeStylusEntity(appObjects.getOrCreate("Stylus"));
    const registerSpy = jest.spyOn(stylus, "registerController");
    const ao = appObjects.getOrCreate("AO");
    const mockUC = new MockRayPanScaleTransformUC(ao);
    const controller = new PanScaleTransformSC(ao);
    return { mockUC, controller, registerSpy };
}
describe("Pan Scene Root Stylus Controller", () => {
    it("Registers", () => {
        const { registerSpy, controller } = makeTestRig();
        expect(registerSpy).toHaveBeenCalledWith(controller);
    });
    it("Initializes on press", () => {
        const { mockUC, controller } = makeTestRig();
        controller.onButtonDown(1);
        expect(mockUC.initialize).toHaveBeenCalled();
    });
    it("Does not initialize if not allowed", () => {
        const { mockUC, controller } = makeTestRig();
        controller.allow = () => {
            return false;
        };
        controller.onButtonDown(1);
        expect(mockUC.initialize).not.toHaveBeenCalled();
    });
    it("Updates on move after an successful press", () => {
        const { mockUC, controller } = makeTestRig();
        controller.onButtonDown(1);
        controller.onStylusMove();
        expect(mockUC.update).toHaveBeenCalled();
    });
    it("Does not updates if not initialized", () => {
        const { mockUC, controller } = makeTestRig();
        controller.onStylusMove();
        expect(mockUC.update).not.toHaveBeenCalled();
    });
    it("Ends after an successful press", () => {
        const { mockUC, controller } = makeTestRig();
        controller.onButtonDown(1);
        controller.onButtonUp();
        expect(mockUC.finish).toHaveBeenCalled();
    });
    it("Does not end if press was not initialized", () => {
        const { mockUC, controller } = makeTestRig();
        controller.onStylusMove();
        controller.onButtonUp();
        expect(mockUC.finish).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=PanScaleTransformSC.test.js.map