MCPcopy
hub / github.com/google-gemini/gemini-cli / renderWithProviders

Function renderWithProviders

packages/cli/src/test-utils/render.tsx:621–830  ·  view source on GitHub ↗
(
  component: React.ReactElement,
  {
    shellFocus = true,
    settings = mockSettings,
    uiState: providedUiState,
    quotaState: providedQuotaState,
    inputState: providedInputState,
    width,
    mouseEventsEnabled = false,
    config,
    uiActions,
    toolActions,
    persistentState,
    appState = mockAppState,
  }: {
    shellFocus?: boolean;
    settings?: LoadedSettings;
    uiState?: Partial<UIState>;
    quotaState?: Partial<QuotaState>;
    inputState?: Partial<InputState>;
    width?: number;
    mouseEventsEnabled?: boolean;
    config?: Config;
    uiActions?: Partial<UIActions>;
    toolActions?: Partial<{
      isExpanded: (callId: string) => boolean;
      toggleExpansion: (callId: string) => void;
      toggleAllExpansion: (callIds: string[]) => void;
    }>;
    persistentState?: {
      get?: typeof persistentStateMock.get;
      set?: typeof persistentStateMock.set;
    };
    appState?: AppState;
  } = {},
)

Source from the content-addressed store, hash-verified

619};
620
621export const renderWithProviders = async (
622 component: React.ReactElement,
623 {
624 shellFocus = true,
625 settings = mockSettings,
626 uiState: providedUiState,
627 quotaState: providedQuotaState,
628 inputState: providedInputState,
629 width,
630 mouseEventsEnabled = false,
631 config,
632 uiActions,
633 toolActions,
634 persistentState,
635 appState = mockAppState,
636 }: {
637 shellFocus?: boolean;
638 settings?: LoadedSettings;
639 uiState?: Partial<UIState>;
640 quotaState?: Partial<QuotaState>;
641 inputState?: Partial<InputState>;
642 width?: number;
643 mouseEventsEnabled?: boolean;
644 config?: Config;
645 uiActions?: Partial<UIActions>;
646 toolActions?: Partial<{
647 isExpanded: (callId: string) => boolean;
648 toggleExpansion: (callId: string) => void;
649 toggleAllExpansion: (callIds: string[]) => void;
650 }>;
651 persistentState?: {
652 get?: typeof persistentStateMock.get;
653 set?: typeof persistentStateMock.set;
654 };
655 appState?: AppState;
656 } = {},
657): Promise<RenderWithProvidersInstance> => {
658 const baseState: UIState = new Proxy(
659 { ...baseMockUiState, ...providedUiState },
660 {
661 get(target, prop) {
662 if (prop in target) {
663 return target[prop as keyof typeof target];
664 }
665 // For properties not in the base mock or provided state,
666 // we'll check the original proxy to see if it's a defined but
667 // unprovided property, and if not, throw.
668 if (prop in baseMockUiState) {
669 return baseMockUiState[prop as keyof typeof baseMockUiState];
670 }
671 throw new Error(`mockUiState does not have property ${String(prop)}`);
672 },
673 },
674 ) as UIState;
675
676 const quotaState: QuotaState = {
677 userTier: undefined,
678 stats: undefined,

Calls 10

makeFakeConfigFunction · 0.85
pickDefaultThemeNameFunction · 0.85
wrapWithProvidersFunction · 0.85
simulateClickFunction · 0.85
mockClearMethod · 0.80
getAllThemesMethod · 0.80
setActiveThemeMethod · 0.80
flatMapMethod · 0.80
renderFunction · 0.70
setTerminalBackgroundMethod · 0.45

Tested by 15

renderDialogFunction · 0.68
renderComponentFunction · 0.68
renderWithMockedStatsFunction · 0.68
renderWithContextFunction · 0.68
renderWithTokensFunction · 0.68
renderDialogFunction · 0.68
renderDialogFunction · 0.68
renderWithMockedStatsFunction · 0.68
renderWithProviderFunction · 0.68
renderToastDisplayFunction · 0.68
renderDetailsFunction · 0.68
renderViewFunction · 0.68