"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const Dispatcher_1 = require("../../Dispatcher");
const OverlayColor_1 = require("../../OverlayColor/Entities/OverlayColor");
const MockUndoRedo_1 = require("../../UndoRedo/Mocks/MockUndoRedo");
const ClearAllColorOverlayUndoRedo_1 = require("./ClearAllColorOverlayUndoRedo");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const ao = appObjects.getOrCreate("App");
    const mockUndo = (0, MockUndoRedo_1.makeMockUndoRedo)(appObjects);
    const submitActionMock = jest.fn();
    mockUndo.submitAction = submitActionMock;
    const mockDispatcher = (0, Dispatcher_1.makeMockDispatchStateChange)(appObjects);
    const doDispatchMock = jest.fn();
    mockDispatcher.doDispatch = doDispatchMock;
    const obj1 = appObjects.getOrCreate("obj1");
    const overlay1 = new OverlayColor_1.OverlayColor(obj1);
    const undoMap = new Map();
    undoMap.set("obj1", OverlayColor_1.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_1.ClearAllColorOverlayUndoRedo(undoMap, appObjects);
        expect(submitActionMock).toHaveBeenCalledWith(action);
    });
    it("Undo Set prior overlay colors", () => {
        const { undoMap, appObjects, overlay1 } = makeTestRig();
        expect(overlay1.overlayColor).toEqual(OverlayColor_1.OverlayColorEnums.NONE);
        const action = new ClearAllColorOverlayUndoRedo_1.ClearAllColorOverlayUndoRedo(undoMap, appObjects);
        action.undoAction();
        expect(overlay1.overlayColor).toEqual(OverlayColor_1.OverlayColorEnums.BLUE);
    });
    it("Redo Set all overlay colors to NONE", () => {
        const { undoMap, appObjects, overlay1 } = makeTestRig();
        const action = new ClearAllColorOverlayUndoRedo_1.ClearAllColorOverlayUndoRedo(undoMap, appObjects);
        action.undoAction();
        action.redoAction();
        expect(overlay1.overlayColor).toEqual(OverlayColor_1.OverlayColorEnums.NONE);
    });
    it("Dispatches state changes for both the undo and redo action", () => {
        const { doDispatchMock, undoMap, appObjects } = makeTestRig();
        const action = new ClearAllColorOverlayUndoRedo_1.ClearAllColorOverlayUndoRedo(undoMap, appObjects);
        action.undoAction();
        expect(doDispatchMock).toHaveBeenCalledTimes(1);
        action.redoAction();
        expect(doDispatchMock).toHaveBeenCalledTimes(2);
    });
});
//# sourceMappingURL=ClearAllColorOverlayUndoRedo.test.js.map