Skip to content

Instantly share code, notes, and snippets.

@johnpmitsch
Created July 8, 2020 19:55
Show Gist options
  • Save johnpmitsch/26581dc2b913e536683c18425148b6a9 to your computer and use it in GitHub Desktop.
Save johnpmitsch/26581dc2b913e536683c18425148b6a9 to your computer and use it in GitHub Desktop.
r-t-lib refactor
diff --git a/webpack/test-utils/react-testing-lib-wrapper.js b/webpack/test-utils/react-testing-lib-wrapper.js
index 7562bc4..c3a023f 100644
--- a/webpack/test-utils/react-testing-lib-wrapper.js
+++ b/webpack/test-utils/react-testing-lib-wrapper.js
@@ -22,8 +22,9 @@ process.env.DEBUG_PRINT_LIMIT = 99999;
function renderWithRedux(
component,
{
- namespace, // redux namespace
- initialState = { response: {}, status: STATUS.PENDING },
+ apiNamespace, // namespace if using API middleware
+ initialApiState = { response: {}, status: STATUS.PENDING }, // Default state for API middleware
+ initialState = {} // Override full state
} = {},
) {
// Adding the reducer in the expected namespaced format
@@ -42,6 +43,7 @@ function renderWithRedux(
settings: initialSettingsState,
},
},
+ ...initialState
});
const middlewares = applyMiddleware(thunk, APIMiddleware);
const store = createStore(combinedReducers, initialFullState, middlewares);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment