webpack/testHelper.js in foreman_ansible-13.0.7 vs webpack/testHelper.js in foreman_ansible-14.0.0

- old
+ new

@@ -1,6 +1,6 @@ -import React from 'react'; +import React, { useState } from 'react'; import { Provider } from 'react-redux'; import thunk from 'redux-thunk'; import { applyMiddleware, createStore, compose, combineReducers } from 'redux'; import { MockedProvider } from '@apollo/react-testing'; import { Router, MemoryRouter } from 'react-router-dom'; @@ -40,23 +40,24 @@ </Router> ); }; export const withMockedProvider = Component => props => { - const ForemanContext = getForemanContext(ctx); - // eslint-disable-next-line react/prop-types - const { mocks, ...rest } = props; - - const ctx = { + const [context, setContext] = useState({ metadata: { UISettings: { perPage: 20, }, }, - }; + }); + const contextData = { context, setContext }; + const ForemanContext = getForemanContext(contextData); + // eslint-disable-next-line react/prop-types + const { mocks, ...rest } = props; + return ( - <ForemanContext.Provider value={ctx}> + <ForemanContext.Provider value={contextData}> <MockedProvider mocks={mocks}> <Component {...rest} /> </MockedProvider> </ForemanContext.Provider> );