import { makeAppObject, makeAppObjectRepo } from "@vived/core";
import { makeBaseAppState } from "../../BaseApp/Entity/BaseAppState";
import { makeStylusEntity } from "../../Stylus/Entity/StylusEntity";
import { makeLabelDropRepo } from "../Entities/LabelDropRepo";
import { makeDragLabelDropWorldUC } from "../UseCases/DragLabelDropWorldUC";
import { makeStylusLabelDrop } from "./StylusLabelDrop";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const ao = appObjects.getOrCreate("ao");
    const baseApp = makeBaseAppState(ao);
    baseApp.isAuthoring = true;
    const appObj = makeAppObject("id1", appObjects);
    const labelDrop = makeLabelDropRepo(appObj);
    const stylus = makeStylusEntity(ao);
    const dragLabelDropUC = makeDragLabelDropWorldUC(ao);
    const stylusLabelDrop = 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();
        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