import { makeAppObjectRepo } from "@vived/core";
import { MockDispatchStateChange } from "../../Dispatcher/Mocks/MockDispatchStateChange";
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 mockDispatcher = new MockDispatchStateChange(ao);
    const obj1 = appObjects.getOrCreate("obj1");
    const overlay1 = new OverlayColor(obj1);
    const undoMap = new Map();
    undoMap.set("obj1", OverlayColorEnums.BLUE);
    return {
        mockUndo,
        mockDispatcher,
        appObjects,
        overlay1,
        undoMap,
    };
}
describe("Clear All Color Overlay Undo Redo action", () => {
    it("Submits itself to the entity", () => {
        const { mockUndo, undoMap, appObjects } = makeTestRig();
        const action = new ClearAllColorOverlayUndoRedo(undoMap, appObjects);
        expect(mockUndo.submitAction).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 { mockDispatcher, undoMap, appObjects } = makeTestRig();
        const action = new ClearAllColorOverlayUndoRedo(undoMap, appObjects);
        action.undoAction();
        expect(mockDispatcher.doDispatch).toHaveBeenCalledTimes(1);
        action.redoAction();
        expect(mockDispatcher.doDispatch).toHaveBeenCalledTimes(2);
    });
});
//# sourceMappingURL=ClearAllColorOverlayUndoRedo.test.js.map