import { makeTransform3D } from "../Entities/Transform3D";
import { makeAppObjectRepo } from "@vived/core";
import { makeMockDispatchStateChange } from "../../Dispatcher";
import { makeStylusEntity } from "../../Stylus/Entity/StylusEntity";
import { MockUndoRedo } from "../../UndoRedo/Mocks/MockUndoRedo";
import { makeStylusMoveTransformUC } from "./StylusMoveTransformUC";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const stylusAO = appObjects.getOrCreate("Stylus");
    const stylus = makeStylusEntity(stylusAO);
    const ao = appObjects.getOrCreate("App Object");
    const transform = makeTransform3D(ao);
    const stylusRootMovementUC = makeStylusMoveTransformUC(ao);
    const mockDispatch = makeMockDispatchStateChange(appObjects);
    const doDispatchMock = jest.fn();
    mockDispatch.doDispatch = doDispatchMock;
    const mockUndo = new MockUndoRedo(ao);
    // Override the submitAction with a jest.fn()
    mockUndo.submitAction = jest.fn();
    return {
        appObjects,
        stylusRootMovementUC,
        transform,
        mockDispatch,
        doDispatchMock,
        mockUndo,
    };
}
describe("Stylus Root Movement UC", () => {
    it("Dispatches a state change on stop if there was movement", () => {
        const { stylusRootMovementUC, doDispatchMock } = makeTestRig();
        stylusRootMovementUC.initialize();
        stylusRootMovementUC.move();
        stylusRootMovementUC.stop();
        expect(doDispatchMock).toHaveBeenCalled();
    });
    it("Does not Dispatches a state change on stop if there was no movement", () => {
        const { stylusRootMovementUC, doDispatchMock } = makeTestRig();
        stylusRootMovementUC.initialize();
        stylusRootMovementUC.stop();
        expect(doDispatchMock).not.toHaveBeenCalled();
    });
    it("Submits an undo on stop if requested", () => {
        const { stylusRootMovementUC, mockUndo } = makeTestRig();
        stylusRootMovementUC.initialize();
        stylusRootMovementUC.move();
        stylusRootMovementUC.stop(true);
        expect(mockUndo.submitAction).toHaveBeenCalled();
    });
    it("Does not submit an undo on stop if not requested", () => {
        const { stylusRootMovementUC, mockUndo } = makeTestRig();
        stylusRootMovementUC.initialize();
        stylusRootMovementUC.move();
        stylusRootMovementUC.stop();
        expect(mockUndo.submitAction).not.toHaveBeenCalled();
    });
    it("Does not submit an undo on stop if request is false", () => {
        const { stylusRootMovementUC, mockUndo } = makeTestRig();
        stylusRootMovementUC.initialize();
        stylusRootMovementUC.move();
        stylusRootMovementUC.stop(false);
        expect(mockUndo.submitAction).not.toHaveBeenCalled();
    });
    it("Does not submits an undo on stop if there was no movement", () => {
        const { stylusRootMovementUC, mockUndo } = makeTestRig();
        stylusRootMovementUC.initialize();
        stylusRootMovementUC.stop(true);
        expect(mockUndo.submitAction).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=StylusMoveTransformUC.test.js.map