import { makeAppObjectRepo } from "@vived/core";
import { makeMockDispatchStateChange } from "../../Dispatcher";
import { OverlayColor, OverlayColorEnums, } from "../../OverlayColor/Entities/OverlayColor";
import { makeMockUndoRedo } from "../../UndoRedo/Mocks/MockUndoRedo";
import { ClearAllColorOverlayUndoRedo } from "./ClearAllColorOverlayUndoRedo";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const ao = appObjects.getOrCreate("App");
    const mockUndo = makeMockUndoRedo(appObjects);
    const submitActionMock = jest.fn();
    mockUndo.submitAction = submitActionMock;
    const mockDispatcher = makeMockDispatchStateChange(appObjects);
    const doDispatchMock = jest.fn();
    mockDispatcher.doDispatch = doDispatchMock;
    const obj1 = appObjects.getOrCreate("obj1");
    const overlay1 = new OverlayColor(obj1);
    const undoMap = new Map();
    undoMap.set("obj1", OverlayColorEnums.BLUE);
    return {
        mockUndo,
        submitActionMock,
        mockDispatcher,
        doDispatchMock,
        appObjects,
        overlay1,
        undoMap,
    };
}
describe("Clear All Color Overlay Undo Redo action", () => {
    it("Submits itself to the entity", () => {
        const { submitActionMock, undoMap, appObjects } = makeTestRig();
        const action = new ClearAllColorOverlayUndoRedo(undoMap, appObjects);
        expect(submitActionMock).toHaveBeenCalledWith(action);
    });
    it("Undo Set prior overlay colors", () => {
        const { undoMap, appObjects, overlay1 } = makeTestRig();
        expect(overlay1.overlayColor).toEqual(OverlayColorEnums.NONE);
        const action = new ClearAllColorOverlayUndoRedo(undoMap, appObjects);
        action.undoAction();
        expect(overlay1.overlayColor).toEqual(OverlayColorEnums.BLUE);
    });
    it("Redo Set all overlay colors to NONE", () => {
        const { undoMap, appObjects, overlay1 } = makeTestRig();
        const action = new ClearAllColorOverlayUndoRedo(undoMap, appObjects);
        action.undoAction();
        action.redoAction();
        expect(overlay1.overlayColor).toEqual(OverlayColorEnums.NONE);
    });
    it("Dispatches state changes for both the undo and redo action", () => {
        const { doDispatchMock, undoMap, appObjects } = makeTestRig();
        const action = new ClearAllColorOverlayUndoRedo(undoMap, appObjects);
        action.undoAction();
        expect(doDispatchMock).toHaveBeenCalledTimes(1);
        action.redoAction();
        expect(doDispatchMock).toHaveBeenCalledTimes(2);
    });
});
//# sourceMappingURL=ClearAllColorOverlayUndoRedo.test.js.map