import { makeAppObjectRepo } from "@vived/core";
import { makeStylusEntity } from "../../../Stylus";
import { MockRayScaleTransform } from "../../Mocks/MockRayScaleTransform";
import { ScaleTransformSC } from "./ScaleTransformSC";
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 MockRayScaleTransform(ao);
    const controller = new ScaleTransformSC(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(0);
        expect(mockUC.initializeRay).toHaveBeenCalled();
    });
    it("Does not initialize if not allowed", () => {
        const { mockUC, controller } = makeTestRig();
        controller.allow = () => {
            return false;
        };
        controller.onButtonDown(0);
        expect(mockUC.initializeRay).not.toHaveBeenCalled();
    });
    it("Updates on move after an successful press", () => {
        const { mockUC, controller } = makeTestRig();
        controller.onButtonDown(0);
        controller.onStylusMove();
        expect(mockUC.updateRay).toHaveBeenCalled();
    });
    it("Does not updates if not initialized", () => {
        const { mockUC, controller } = makeTestRig();
        controller.onStylusMove();
        expect(mockUC.updateRay).not.toHaveBeenCalled();
    });
    it("Ends after an successful press", () => {
        const { mockUC, controller } = makeTestRig();
        controller.onButtonDown(0);
        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=ScaleTransformSC.test.js.map