mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
3c6e0e8ef8
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { AnyAction, configureStore } from '@reduxjs/toolkit';
|
|
import { ThunkMiddlewareFor } from '@reduxjs/toolkit/dist/getDefaultMiddleware';
|
|
import { render as rtlRender } from '@testing-library/react';
|
|
import React from 'react';
|
|
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 { render };
|