import { makeAppObjectRepo } from "@vived/core";
import { makeMockShowMarkdownEditor } from "../../Dispatcher";
import { MockDispatchStateChange } from "../../Dispatcher/Mocks/MockDispatchStateChange";
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 = new MockDispatchStateChange(app);
    const mockShowMarkDownEditor = makeMockShowMarkdownEditor(appObjects);
    return {
        appState,
        editSlideTextUC,
        mockDispatchStateChange,
        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, mockDispatchStateChange } = makeTestRig();
        appState.slideText = "Slide Text";
        editSlideTextUC.submitCallback("Slide Text");
        expect(mockDispatchStateChange.doDispatch).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, mockDispatchStateChange } = makeTestRig();
        appState.slideText = "Slide Text";
        editSlideTextUC.submitCallback("New slide Text");
        expect(mockDispatchStateChange.doDispatch).toHaveBeenCalled();
    });
});
//# sourceMappingURL=EditSlideTextUC.test.js.map