"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const BaseAppState_1 = require("../../BaseApp/Entity/BaseAppState");
const StylusEntity_1 = require("../../Stylus/Entity/StylusEntity");
const LabelDropRepo_1 = require("../Entities/LabelDropRepo");
const DragLabelDropWorldUC_1 = require("../UseCases/DragLabelDropWorldUC");
const StylusLabelDrop_1 = require("./StylusLabelDrop");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const ao = appObjects.getOrCreate("ao");
    const baseApp = (0, BaseAppState_1.makeBaseAppState)(ao);
    baseApp.isAuthoring = true;
    const appObj = (0, core_1.makeAppObject)("id1", appObjects);
    const labelDrop = (0, LabelDropRepo_1.makeLabelDropRepo)(appObj);
    const stylus = (0, StylusEntity_1.makeStylusEntity)(ao);
    const dragLabelDropUC = (0, DragLabelDropWorldUC_1.makeDragLabelDropWorldUC)(ao);
    const stylusLabelDrop = (0, StylusLabelDrop_1.makeStylusLabelDrop)(ao);
    return {
        ao,
        appObjects,
        labelDrop,
        dragLabelDropUC,
        stylus,
        stylusLabelDrop,
    };
}
describe("Stylus Label Drop", () => {
    it("Registers as a stylus controller", () => {
        const { stylus, ao } = makeTestRig();
        stylus.registerController = jest.fn();
        (0, StylusLabelDrop_1.makeStylusLabelDrop)(ao);
        expect(stylus.registerController).toHaveBeenCalled();
    });
    it("Sets the 3D position on move if a label drop is being dragged", () => {
        const { labelDrop, dragLabelDropUC, stylusLabelDrop } = makeTestRig();
        labelDrop.draggingID = "id123";
        dragLabelDropUC.updateDrag = jest.fn();
        stylusLabelDrop.onStylusMove();
        expect(dragLabelDropUC.updateDrag).toHaveBeenCalled();
    });
    it("Dpes not sets the 3D position on move if a label drop is not being dragged", () => {
        const { labelDrop, dragLabelDropUC, stylusLabelDrop } = makeTestRig();
        labelDrop.draggingID = undefined;
        dragLabelDropUC.updateDrag = jest.fn();
        stylusLabelDrop.onStylusMove();
        expect(dragLabelDropUC.updateDrag).not.toHaveBeenCalled();
    });
    it("Calls release on up if a label drop is being dragged", () => {
        const { labelDrop, dragLabelDropUC, stylusLabelDrop } = makeTestRig();
        labelDrop.draggingID = "id123";
        dragLabelDropUC.releaseDrag = jest.fn();
        stylusLabelDrop.onButtonUp(0);
        expect(dragLabelDropUC.releaseDrag).toHaveBeenCalled();
    });
    it("Does not call release on up if a label drop is being dragged", () => {
        const { labelDrop, dragLabelDropUC, stylusLabelDrop } = makeTestRig();
        labelDrop.draggingID = undefined;
        dragLabelDropUC.releaseDrag = jest.fn();
        stylusLabelDrop.onButtonUp(0);
        expect(dragLabelDropUC.releaseDrag).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=StylusLabelDrop.test.js.map