mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import React from 'react';
|
|
import { render as rtlRender } from '@testing-library/react';
|
|
import { AnyAction, configureStore } from '@reduxjs/toolkit';
|
|
import { ThunkMiddlewareFor } from '@reduxjs/toolkit/dist/getDefaultMiddleware';
|
|
import { Provider } from 'react-redux';
|
|
import { createRootReducer } from 'app/core/reducers/root';
|
|
import { StoreState } from 'app/types';
|
|
import { mockNavModel } from './mocks/navModel';
|
|
|
|
function render(
|
|
ui: React.ReactElement,
|
|
{
|
|
preloadedState = { navIndex: mockNavModel },
|
|
store = configureStore<
|
|
StoreState,
|
|
AnyAction,
|
|
ReadonlyArray<ThunkMiddlewareFor<StoreState, { thunk: true; serializableCheck: false; immutableCheck: false }>>
|
|
>({
|
|
reducer: createRootReducer(),
|
|
preloadedState,
|
|
middleware: (getDefaultMiddleware) =>
|
|
getDefaultMiddleware({ thunk: true, serializableCheck: false, immutableCheck: false }),
|
|
}),
|
|
...renderOptions
|
|
}: { preloadedState?: Partial<StoreState>; store?: ReturnType<typeof configureStore> } = {}
|
|
) {
|
|
function Wrapper({ children }: { children: React.ReactNode }) {
|
|
return <Provider store={store}>{children}</Provider>;
|
|
}
|
|
|
|
return rtlRender(ui, { wrapper: Wrapper, ...renderOptions });
|
|
}
|
|
|
|
export * from '@testing-library/react';
|
|
export { render };
|