chore: Adds QueryParamProvider to testing helper (#14195)

This commit is contained in:
Michael S. Molina 2021-05-06 01:58:40 -03:00 committed by GitHub
parent fa0915d9e6
commit fa510df624
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,16 +26,19 @@ import thunk from 'redux-thunk';
import { DndProvider } from 'react-dnd'; import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend'; import { HTML5Backend } from 'react-dnd-html5-backend';
import reducerIndex from 'spec/helpers/reducerIndex'; import reducerIndex from 'spec/helpers/reducerIndex';
import { QueryParamProvider } from 'use-query-params';
type Options = Omit<RenderOptions, 'queries'> & { type Options = Omit<RenderOptions, 'queries'> & {
useRedux?: boolean; useRedux?: boolean;
useDnd?: boolean; useDnd?: boolean;
useQueryParams?: boolean;
initialState?: {}; initialState?: {};
reducers?: {}; reducers?: {};
}; };
function createWrapper(options?: Options) { function createWrapper(options?: Options) {
const { useDnd, useRedux, initialState, reducers } = options || {}; const { useDnd, useRedux, useQueryParams, initialState, reducers } =
options || {};
return ({ children }: { children?: ReactNode }) => { return ({ children }: { children?: ReactNode }) => {
let result = ( let result = (
@ -56,6 +59,10 @@ function createWrapper(options?: Options) {
result = <Provider store={store}>{result}</Provider>; result = <Provider store={store}>{result}</Provider>;
} }
if (useQueryParams) {
result = <QueryParamProvider>{result}</QueryParamProvider>;
}
return result; return result;
}; };
} }