mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* update eslint, tsconfig + esbuild to handle new jsx transform * remove thing that breaks the new jsx transform * remove react imports * adjust grafana-icons build * is this the correct syntax? * try this * well this was much easier than expected... * change grafana-plugin-configs webpack config * fixes * fix lockfile * fix 2 more violations * use path.resolve instead of require.resolve * remove react import * fix react imports * more fixes * remove React import * remove import React from docs * remove another react import
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { Store } from '@reduxjs/toolkit';
|
|
import * as React from 'react';
|
|
import { Provider } from 'react-redux';
|
|
import { Router } from 'react-router-dom';
|
|
import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock';
|
|
|
|
import { locationService } from '@grafana/runtime';
|
|
import { ModalRoot } from '@grafana/ui';
|
|
import { GrafanaContext, GrafanaContextType } from 'app/core/context/GrafanaContext';
|
|
import { ModalsContextProvider } from 'app/core/context/ModalsContextProvider';
|
|
import { configureStore } from 'app/store/configureStore';
|
|
import { StoreState } from 'app/types/store';
|
|
|
|
export interface Props {
|
|
storeState?: Partial<StoreState>;
|
|
store?: Store<StoreState>;
|
|
children: React.ReactNode;
|
|
grafanaContext?: GrafanaContextType;
|
|
}
|
|
|
|
/**
|
|
* Wrapps component in redux store provider, Router and GrafanaContext
|
|
*
|
|
* @deprecated Use `test/test-utils` `render` method instead
|
|
*/
|
|
export function TestProvider(props: Props) {
|
|
const { store = configureStore(props.storeState), children } = props;
|
|
|
|
const context = {
|
|
...getGrafanaContextMock(),
|
|
...props.grafanaContext,
|
|
};
|
|
|
|
return (
|
|
<Provider store={store}>
|
|
<Router history={locationService.getHistory()}>
|
|
<ModalsContextProvider>
|
|
<GrafanaContext.Provider value={context}>{children}</GrafanaContext.Provider>
|
|
<ModalRoot />
|
|
</ModalsContextProvider>
|
|
</Router>
|
|
</Provider>
|
|
);
|
|
}
|