"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const Dispatcher_1 = require("../../Dispatcher");
const UndoRedoEntity_1 = require("../../UndoRedo/Entities/UndoRedoEntity");
const BaseAppState_1 = require("../Entity/BaseAppState");
const EditSlideTextUC_1 = require("./EditSlideTextUC");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const app = appObjects.getOrCreate("App");
    const appState = (0, BaseAppState_1.makeBaseAppState)(app);
    const editSlideTextUC = (0, EditSlideTextUC_1.makeEditSlideTextUC)(app);
    (0, UndoRedoEntity_1.makeUndoRedoEntity)(app);
    const mockDispatchStateChange = (0, Dispatcher_1.makeMockDispatchStateChange)(appObjects);
    const doDispatchMock = jest.fn();
    mockDispatchStateChange.doDispatch = doDispatchMock;
    const mockShowMarkDownEditor = (0, Dispatcher_1.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