"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const MockTouchInput_1 = require("../../../TouchController/Mock/MockTouchInput");
const mockTouchInputEvent_1 = require("../../../TouchController/Mock/mockTouchInputEvent");
const Mocks_1 = require("../../Mocks");
const DragScaleTransformTC_1 = require("./DragScaleTransformTC");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const app = appObjects.getOrCreate("app");
    new MockTouchInput_1.MockTouchInputEntity(app);
    const appObj = appObjects.getOrCreate("AO");
    const mockZoom = new Mocks_1.MockRayScaleTransform(appObj);
    const zoomController = new DragScaleTransformTC_1.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 = (0, mockTouchInputEvent_1.mockTouchInputEvent)([new core_1.Vector2(79, 0)]);
        zoomController.onTouchStart(input);
        expect(mockZoom.initializePixel).toHaveBeenCalledWith(new core_1.Vector2(79, 0));
    });
    it("Does not initialize if allow return false", () => {
        const { zoomController, mockZoom } = makeTestRig();
        zoomController.allow = () => {
            return false;
        };
        const input = (0, mockTouchInputEvent_1.mockTouchInputEvent)([new core_1.Vector2(0, 0), new core_1.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 = (0, mockTouchInputEvent_1.mockTouchInputEvent)([new core_1.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