import { makeAppObjectRepo } from "@vived/core";
import { makeMockDispatchStateChange } from "../../Dispatcher/Mocks/MockDispatchStateChange";
import { Hideable } from "../../Hideable/Entities/Hideable";
import { makeMockUndoRedo } from "../../UndoRedo/Mocks/MockUndoRedo";
import { UnhideAllAppObjectsUndoRedo } from "./UnhideAllAppObjectsUndoRedo";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const ao = appObjects.getOrCreate("App");
    const mockDispatchStateChange = makeMockDispatchStateChange(appObjects);
    const doDispatchMock = jest.fn();
    mockDispatchStateChange.doDispatch = doDispatchMock;
    const sm1 = appObjects.getOrCreate("sm1");
    const sm2 = appObjects.getOrCreate("sm2");
    const sm1Hideable = new Hideable(sm1);
    const sm2Hideable = new Hideable(sm2);
    const hiddenObjects = ["sm1", "sm2"];
    makeMockUndoRedo(appObjects);
    return {
        appObjects,
        sm1Hideable,
        sm2Hideable,
        doDispatchMock,
        hiddenObjects,
    };
}
describe("UnhideAllAppObjectsUndoRedo", () => {
    it("Undo hide App Object action", () => {
        const { appObjects, sm1Hideable, sm2Hideable, doDispatchMock, hiddenObjects, } = makeTestRig();
        doDispatchMock.mockClear();
        const action = new UnhideAllAppObjectsUndoRedo(hiddenObjects, appObjects);
        action.undoAction();
        expect(sm1Hideable.isHidden).toEqual(true);
        expect(sm2Hideable.isHidden).toEqual(true);
        expect(doDispatchMock).toHaveBeenCalled();
    });
    it("Redo hide App Object action", () => {
        const { appObjects, hiddenObjects, sm1Hideable, sm2Hideable, doDispatchMock, } = makeTestRig();
        const action = new UnhideAllAppObjectsUndoRedo(hiddenObjects, appObjects);
        action.undoAction();
        doDispatchMock.mockClear();
        action.redoAction();
        expect(sm1Hideable.isHidden).toEqual(false);
        expect(sm2Hideable.isHidden).toEqual(false);
        expect(doDispatchMock).toHaveBeenCalled();
    });
});
//# sourceMappingURL=UnhideAllAppObjectsUndoRedo.test.js.map