import { makeAppObjectRepo, ParametricLine, Vector3 } from "@vived/core";
import { makeMockPixelToSceneRayUC, makeMockSceneRayPickUC, } from "../../Babylon/Mocks";
import { makeToolRepo } from "../../Tools";
import { MockPanTransformUC } from "../../Transform3D/Mocks/MockPanTransformUC";
import { makeCalloutEntity } from "../Entities/CalloutEntity";
import { makeTryPanLabelUC } from "./TryPanLabelUC";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const tryDragAO = appObjects.getOrCreate("tryDragAO");
    const uc = makeTryPanLabelUC(tryDragAO);
    const calloutAO = appObjects.getOrCreate("callout");
    const callout = makeCalloutEntity(calloutAO);
    const panTransformUC = new MockPanTransformUC(callout.labelTransform.appObject);
    const mockPixelToRay = makeMockPixelToSceneRayUC(appObjects);
    const mockPickUC = makeMockSceneRayPickUC(appObjects);
    const mockPickResult = {
        hit: true,
        worldPickPoint: new Vector3(1, 2, 3),
        appObjectID: "callout",
    };
    const mockPick = jest.fn().mockReturnValue(mockPickResult);
    mockPickUC.sceneRayPick = mockPick;
    const toolRepo = 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(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(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(appObjects.getOrCreate("somethingElse"));
        expect(uc.tryWithRay(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";
        makeCalloutEntity(appObjects.getOrCreate("somethingElse"));
        expect(uc.tryWithRay(ParametricLine.Forward())).toEqual(false);
    });
    it("Initializes the peel UC", () => {
        const { uc, panTransformUC } = makeTestRig();
        uc.tryWithRay(ParametricLine.Forward());
        expect(panTransformUC.initializeRay).toHaveBeenCalledWith(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