Skip to content

Commit

Permalink
Fixes #37245 - 25 tests failing with "TypeError: Cannot read property…
Browse files Browse the repository at this point in the history
… 'perPage' of undefined"
  • Loading branch information
Thorben-D authored and nofaralfasi committed Mar 19, 2024
1 parent e21fbc2 commit 09517d6
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions webpack/testHelper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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';
Expand Down Expand Up @@ -42,20 +42,21 @@ export const withReactRouter = Component => props => {
};

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>
Expand Down

0 comments on commit 09517d6

Please sign in to comment.