import { makeAppObjectRepo } from "@vived/core";
import { makeMockDispatchStateChange, makeMockShowMarkdownEditor, } from "../../Dispatcher";
import { makeUndoRedoEntity } from "../../UndoRedo/Entities/UndoRedoEntity";
import { makeBaseAppState } from "../Entity/BaseAppState";
import { makeEditSlideTextUC } from "./EditSlideTextUC";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const app = appObjects.getOrCreate("App");
    const appState = makeBaseAppState(app);
    const editSlideTextUC = makeEditSlideTextUC(app);
    makeUndoRedoEntity(app);
    const mockDispatchStateChange = makeMockDispatchStateChange(appObjects);
    const doDispatchMock = jest.fn();
    mockDispatchStateChange.doDispatch = doDispatchMock;
    const mockShowMarkDownEditor = makeMockShowMarkdownEditor(appObjects);
    return {
        appState,
        editSlideTextUC,
        mockDispatchStateChange,
        doDispatchMock,
        mockShowMarkDownEditor,
        appObjects,
    };
}
describe("EditSlideText UC", () => {
    it("Dispatches showMarkDownEditor", () => {
        const { editSlideTextUC, mockShowMarkDownEditor } = makeTestRig();
        editSlideTextUC.editSlideText();
        expect(mockShowMarkDownEditor.showMarkdownEditor).toHaveBeenCalled();
    });
    it("Doesn't Dispatch state change when the slide text was not changed", () => {
        const { appState, editSlideTextUC, doDispatchMock } = makeTestRig();
        appState.slideText = "Slide Text";
        editSlideTextUC.submitCallback("Slide Text");
        expect(doDispatchMock).not.toHaveBeenCalled();
    });
    it("Stores new slide text when the slide text was changed", () => {
        const { appState, editSlideTextUC } = makeTestRig();
        appState.slideText = "Slide Text";
        editSlideTextUC.submitCallback("New slide Text");
        expect(appState.slideText).toEqual("New slide Text");
    });
    it("Dispatches state change when the slide text was changed", () => {
        const { appState, editSlideTextUC, doDispatchMock } = makeTestRig();
        appState.slideText = "Slide Text";
        editSlideTextUC.submitCallback("New slide Text");
        expect(doDispatchMock).toHaveBeenCalled();
    });
});
//# sourceMappingURL=EditSlideTextUC.test.js.map