import { makeAppObjectRepo } from "@vived/core";
import { ParametricLine, Vector2 } from "@vived/core";
import { makeMockPixelToSceneRayUC } from "../../Babylon/Mocks/MockPixelToSceneRayUC";
import { makeFramedScreen, makeFramedScreenContainer, } from "../../FramedScreen/Entities";
import { makeFramedContainerPM } from "../../FramedScreen/PM/FramedContainerPM";
import { makeLabelDropRepo } from "../Entities/LabelDropRepo";
import { makeMockDragLabelDropUC } from "../Mocks/MockDragLabelDropUC";
import { releaseLabelDropAnswerItemScreen } from "./releaseLabelDropAnswerItemScreen";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const ao = appObjects.getOrCreate("ao");
    const labelDropEntity = makeLabelDropRepo(ao);
    const mockUC = makeMockDragLabelDropUC(appObjects);
    labelDropEntity.makeLabelDropItem("labelDropTestID");
    const pixelToSceneRayUC = makeMockPixelToSceneRayUC(appObjects).pixelToSceneRay.mockReturnValue(ParametricLine.Forward());
    return { appObjects, ao, labelDropEntity, mockUC, pixelToSceneRayUC };
}
describe("Release Drag Label Drop Answer Item", () => {
    it("Calls release on the UC", () => {
        const { mockUC, appObjects } = makeTestRig();
        mockUC.release.mockClear();
        releaseLabelDropAnswerItemScreen(10, 20, appObjects);
        expect(mockUC.release).toHaveBeenCalledWith(ParametricLine.Forward());
    });
    it("Offsets with the render canvas if it exists", () => {
        const { mockUC, appObjects, pixelToSceneRayUC } = makeTestRig();
        mockUC.release.mockClear();
        const framedScreen = makeFramedScreen(appObjects.getOrCreate("FramedScreen"));
        const ao = appObjects.getOrCreate("Render_Canvas");
        const renderCanvas = makeFramedScreenContainer(ao);
        makeFramedContainerPM(ao);
        framedScreen.addContainer(renderCanvas);
        renderCanvas.position = new Vector2(1, 2);
        const releasePos = new Vector2(10, 20);
        const expectedOffSet = new Vector2(releasePos.x - renderCanvas.position.x, releasePos.y - renderCanvas.position.y);
        releaseLabelDropAnswerItemScreen(10, 20, appObjects);
        expect(pixelToSceneRayUC).toHaveBeenCalledWith(expectedOffSet);
    });
});
//# sourceMappingURL=releaseLabelDropAnswerItemScreen.test.js.map