import { makeAppObjectRepo } from "@vived/core";
import { makeMockDispatchStateChange } from "../../Dispatcher/Mocks/MockDispatchStateChange";
import { Hideable } from "../../Hideable/Entities/Hideable";
import { makeChannelModelEntity } from "../Entities";
import { makeUnhideAllChannelModelObjectsUC } from "./UnhideAllChannelModelObjectsUC";
import { UnhideAllAppObjectsUndoRedo } from "./UnhideAllAppObjectsUndoRedo";
jest.mock("./UnhideAllAppObjectsUndoRedo");
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const mockDispatchStateChange = makeMockDispatchStateChange(appObjects);
    const doDispatchMock = jest.fn();
    mockDispatchStateChange.doDispatch = doDispatchMock;
    const ao = appObjects.getOrCreate("ChannelModel");
    const channelModel = makeChannelModelEntity(ao);
    const uc = makeUnhideAllChannelModelObjectsUC(ao);
    const dm1 = channelModel.addModelObject("modelId");
    const dm2 = channelModel.addModelObject("modelId");
    const sm1Hideable = Hideable.addIfMissing(dm1.appObject);
    const sm2Hideable = Hideable.addIfMissing(dm2.appObject);
    if (sm1Hideable && sm2Hideable) {
        sm1Hideable.isHidden = true;
        sm2Hideable.isHidden = true;
    }
    return {
        uc,
        sm1Hideable,
        sm2Hideable,
        doDispatchMock,
    };
}
describe("uc", () => {
    it("Doesn't submit UnhideAllDissectableMeshesUndoRedo action when hidden dissectable meshes are not found", () => {
        const { uc, sm1Hideable, sm2Hideable } = makeTestRig();
        sm1Hideable.isHidden = false;
        sm2Hideable.isHidden = false;
        uc.unhideAll();
        expect(UnhideAllAppObjectsUndoRedo).not.toHaveBeenCalled();
    });
    it("Unhides all channel model objects", () => {
        const { uc, sm1Hideable, sm2Hideable } = makeTestRig();
        uc.unhideAll();
        expect(sm1Hideable.isHidden).toEqual(false);
        expect(sm2Hideable.isHidden).toEqual(false);
    });
    it("Submits UnhideAllDissociableMeshesUndoRedo action", () => {
        const { uc } = makeTestRig();
        uc.unhideAll();
        expect(UnhideAllAppObjectsUndoRedo).toHaveBeenCalled();
    });
    it("Dispatches state change", () => {
        const { uc, doDispatchMock } = makeTestRig();
        uc.unhideAll();
        expect(doDispatchMock).toHaveBeenCalled();
    });
    it("Doesn't dispatch state change when hidden dissectable meshes are not found", () => {
        const { uc, sm1Hideable, sm2Hideable, doDispatchMock } = makeTestRig();
        sm1Hideable.isHidden = false;
        sm2Hideable.isHidden = false;
        uc.unhideAll();
        expect(doDispatchMock).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=UnhideAllChannelModelObjectsUC.test.js.map