import { makeAppObjectRepo, Vector2 } from "@vived/core";
import { MockTouchInputEntity } from "../../../TouchController/Mock/MockTouchInput";
import { mockTouchInputEvent } from "../../../TouchController/Mock/mockTouchInputEvent";
import { MockRayScaleTransform } from "../../Mocks";
import { DragScaleTransformTC } from "./DragScaleTransformTC";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const app = appObjects.getOrCreate("app");
    new MockTouchInputEntity(app);
    const appObj = appObjects.getOrCreate("AO");
    const mockZoom = new MockRayScaleTransform(appObj);
    const zoomController = new DragScaleTransformTC(appObj);
    return { zoomController, mockZoom };
}
describe("Touch Zoom Controller", () => {
    it("Initializes if allow return true", () => {
        const { zoomController, mockZoom } = makeTestRig();
        zoomController.allow = () => {
            return true;
        };
        const input = mockTouchInputEvent([new Vector2(79, 0)]);
        zoomController.onTouchStart(input);
        expect(mockZoom.initializePixel).toHaveBeenCalledWith(new Vector2(79, 0));
    });
    it("Does not initialize if allow return false", () => {
        const { zoomController, mockZoom } = makeTestRig();
        zoomController.allow = () => {
            return false;
        };
        const input = mockTouchInputEvent([new Vector2(0, 0), new Vector2(79, 0)]);
        zoomController.onTouchStart(input);
        expect(mockZoom.initializePixel).not.toHaveBeenCalled();
    });
    it("Does not send zoom if not initialized", () => {
        const { zoomController, mockZoom } = makeTestRig();
        const moveInput = mockTouchInputEvent([new Vector2(-50, 0)]);
        zoomController.onTouchMove(moveInput);
        expect(mockZoom.updatePixel).not.toHaveBeenCalled();
    });
    it("Finializes at the end", () => {
        const { zoomController, mockZoom } = makeTestRig();
        zoomController.onTouchEnd();
        expect(mockZoom.finish).toHaveBeenCalled();
    });
});
//# sourceMappingURL=DragScaleTransformTC.test.js.map