"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const core_2 = require("@vived/core");
const MockPixelToSceneRayUC_1 = require("../../Babylon/Mocks/MockPixelToSceneRayUC");
const Entities_1 = require("../../FramedScreen/Entities");
const FramedContainerPM_1 = require("../../FramedScreen/PM/FramedContainerPM");
const LabelDropRepo_1 = require("../Entities/LabelDropRepo");
const MockDragLabelDropUC_1 = require("../Mocks/MockDragLabelDropUC");
const releaseLabelDropAnswerItemScreen_1 = require("./releaseLabelDropAnswerItemScreen");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const ao = appObjects.getOrCreate("ao");
    const labelDropEntity = (0, LabelDropRepo_1.makeLabelDropRepo)(ao);
    const mockUC = (0, MockDragLabelDropUC_1.makeMockDragLabelDropUC)(appObjects);
    labelDropEntity.makeLabelDropItem("labelDropTestID");
    const pixelToSceneRayUC = (0, MockPixelToSceneRayUC_1.makeMockPixelToSceneRayUC)(appObjects).pixelToSceneRay.mockReturnValue(core_2.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();
        (0, releaseLabelDropAnswerItemScreen_1.releaseLabelDropAnswerItemScreen)(10, 20, appObjects);
        expect(mockUC.release).toHaveBeenCalledWith(core_2.ParametricLine.Forward());
    });
    it("Offsets with the render canvas if it exists", () => {
        const { mockUC, appObjects, pixelToSceneRayUC } = makeTestRig();
        mockUC.release.mockClear();
        const framedScreen = (0, Entities_1.makeFramedScreen)(appObjects.getOrCreate("FramedScreen"));
        const ao = appObjects.getOrCreate("Render_Canvas");
        const renderCanvas = (0, Entities_1.makeFramedScreenContainer)(ao);
        (0, FramedContainerPM_1.makeFramedContainerPM)(ao);
        framedScreen.addContainer(renderCanvas);
        renderCanvas.position = new core_2.Vector2(1, 2);
        const releasePos = new core_2.Vector2(10, 20);
        const expectedOffSet = new core_2.Vector2(releasePos.x - renderCanvas.position.x, releasePos.y - renderCanvas.position.y);
        (0, releaseLabelDropAnswerItemScreen_1.releaseLabelDropAnswerItemScreen)(10, 20, appObjects);
        expect(pixelToSceneRayUC).toHaveBeenCalledWith(expectedOffSet);
    });
});
//# sourceMappingURL=releaseLabelDropAnswerItemScreen.test.js.map