"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const Mocks_1 = require("../../Babylon/Mocks");
const Tools_1 = require("../../Tools");
const MockPanTransformUC_1 = require("../../Transform3D/Mocks/MockPanTransformUC");
const CalloutEntity_1 = require("../Entities/CalloutEntity");
const TryPanLabelUC_1 = require("./TryPanLabelUC");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const tryDragAO = appObjects.getOrCreate("tryDragAO");
    const uc = (0, TryPanLabelUC_1.makeTryPanLabelUC)(tryDragAO);
    const calloutAO = appObjects.getOrCreate("callout");
    const callout = (0, CalloutEntity_1.makeCalloutEntity)(calloutAO);
    const panTransformUC = new MockPanTransformUC_1.MockPanTransformUC(callout.labelTransform.appObject);
    const mockPixelToRay = (0, Mocks_1.makeMockPixelToSceneRayUC)(appObjects);
    const mockPickUC = (0, Mocks_1.makeMockSceneRayPickUC)(appObjects);
    const mockPickResult = {
        hit: true,
        worldPickPoint: new core_1.Vector3(1, 2, 3),
        appObjectID: "callout",
    };
    const mockPick = jest.fn().mockReturnValue(mockPickResult);
    mockPickUC.sceneRayPick = mockPick;
    const toolRepo = (0, Tools_1.makeToolRepo)(appObjects.getOrCreate("ToolRepo"));
    toolRepo.makeTool("PEEL");
    toolRepo.makeTool("CALLOUT");
    toolRepo.makeTool("OTHER");
    toolRepo.triggerTool("PEEL");
    return {
        appObjects,
        uc,
        mockPickResult,
        panTransformUC,
        mockPixelToRay,
        toolRepo,
    };
}
describe("Default Try Screen Drag Transform UC", () => {
    it("Returns true if the initialization is successful", () => {
        const { uc } = makeTestRig();
        expect(uc.tryWithRay(core_1.ParametricLine.Forward())).toEqual(true);
    });
    it("Returns false if the pick doesn't return an app id", () => {
        const { mockPickResult, uc } = makeTestRig();
        mockPickResult.appObjectID = undefined;
        expect(uc.tryWithRay(core_1.ParametricLine.Forward())).toEqual(false);
    });
    it("Returns false if the picked app object doesn't have a Callout Entity", () => {
        const { mockPickResult, uc, appObjects } = makeTestRig();
        mockPickResult.appObjectID = "somethingElse";
        new MockPanTransformUC_1.MockPanTransformUC(appObjects.getOrCreate("somethingElse"));
        expect(uc.tryWithRay(core_1.ParametricLine.Forward())).toEqual(false);
    });
    it("Returns false if the picked app object doesn't have a PanTransformUC", () => {
        const { mockPickResult, uc, appObjects } = makeTestRig();
        mockPickResult.appObjectID = "somethingElse";
        (0, CalloutEntity_1.makeCalloutEntity)(appObjects.getOrCreate("somethingElse"));
        expect(uc.tryWithRay(core_1.ParametricLine.Forward())).toEqual(false);
    });
    it("Initializes the peel UC", () => {
        const { uc, panTransformUC } = makeTestRig();
        uc.tryWithRay(core_1.ParametricLine.Forward());
        expect(panTransformUC.initializeRay).toHaveBeenCalledWith(core_1.ParametricLine.Forward());
    });
    it("Does not allow if the tool is not Callout or Peel", () => {
        const { uc, toolRepo } = makeTestRig();
        toolRepo.triggerTool("OTHER");
        expect(uc.allow()).toEqual(false);
        toolRepo.triggerTool("CALLOUT");
        expect(uc.allow()).toEqual(true);
        toolRepo.triggerTool("OTHER");
        expect(uc.allow()).toEqual(false);
        toolRepo.triggerTool("PEEL");
        expect(uc.allow()).toEqual(true);
    });
});
//# sourceMappingURL=TryPanLabelUC.test.js.map