mirror of
https://github.com/grafana/grafana.git
synced 2025-01-06 22:23:19 -06:00
670960f70c
* update packages * fix type errors * upgrade redux toolkit as well * don't need eslint-disable command * remove comment * fix unit tests * call rtk query selector directly * remove unnecessary checks
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { Store } from '@reduxjs/toolkit';
|
|
import 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>
|
|
);
|
|
}
|