import { makeAppObjectRepo } from "@vived/core";
import { makeMockDispatchStateChange } from "../../Dispatcher/Mocks/MockDispatchStateChange";
import { OverlayColor, OverlayColorEnums, } from "../../OverlayColor/Entities/OverlayColor";
import { makeChannelModelEntity } from "../Entities";
import { ClearAllColorOverlayUndoRedo } from "./ClearAllColorOverlayUndoRedo";
import { makeClearModelObjectOverlaysUC } from "./ClearModelObjectOverlaysUC";
jest.mock("./ClearAllColorOverlayUndoRedo");
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 = makeClearModelObjectOverlaysUC(ao);
    const model1 = channelModel.addModelObject("model1");
    const model2 = channelModel.addModelObject("model2");
    const overlay1 = new OverlayColor(model1.appObject);
    const overlay2 = new OverlayColor(model2.appObject);
    overlay1.overlayColor = OverlayColorEnums.BLACK;
    overlay2.overlayColor = OverlayColorEnums.BLUE;
    return {
        uc,
        overlay1,
        overlay2,
        mockDispatchStateChange,
        doDispatchMock,
    };
}
describe("uc", () => {
    it("Doesn't submit UnhideAllDissectableMeshesUndoRedo action when hidden dissectable meshes are not found", () => {
        const { uc, overlay1, overlay2 } = makeTestRig();
        overlay1.overlayColor = OverlayColorEnums.NONE;
        overlay2.overlayColor = OverlayColorEnums.NONE;
        uc.clearOverlays();
        expect(ClearAllColorOverlayUndoRedo).not.toHaveBeenCalled();
    });
    it("Clears all the overlays", () => {
        const { uc, overlay1, overlay2 } = makeTestRig();
        uc.clearOverlays();
        expect(overlay1.overlayColor).toEqual(OverlayColorEnums.NONE);
        expect(overlay2.overlayColor).toEqual(OverlayColorEnums.NONE);
    });
    it("Submits UnhideAllDissectableMeshesUndoRedo action", () => {
        const { uc } = makeTestRig();
        uc.clearOverlays();
        expect(ClearAllColorOverlayUndoRedo).toHaveBeenCalled();
    });
    it("Dispatches state change", () => {
        const { uc, doDispatchMock } = makeTestRig();
        uc.clearOverlays();
        expect(doDispatchMock).toHaveBeenCalled();
    });
    it("Doesn't dispatch state change when hidden dissectable meshes are not found", () => {
        const { uc, overlay1, overlay2, doDispatchMock } = makeTestRig();
        overlay1.overlayColor = OverlayColorEnums.NONE;
        overlay2.overlayColor = OverlayColorEnums.NONE;
        uc.clearOverlays();
        expect(doDispatchMock).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=ClearModelObjectOverlaysUC.test.js.map