Created
August 3, 2021 22:37
-
-
Save BrianJenney/c0e993fb48d69590262a3291c5853a06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function renderWithRedux(component, { store } = {}) { | |
const rendered = render( | |
<BrowserRouter> | |
<ThemeProvider theme="bri"> | |
<Provider store={store}>{component}</Provider> | |
</ThemeProvider> | |
</BrowserRouter> | |
); | |
// return the methods and properties from our custom render | |
return { | |
...rendered, | |
rerender: (el) => renderWithRedux(el, { store }), | |
store | |
}; | |
} | |
// create a fake redux store with the option to add | |
// properties for scenarios we might want to test | |
export const createReduxStore = (options = {}) => { | |
const defaultOpts = { | |
currentUser: { | |
data: { | |
firstName: 'Cool Dude', | |
} | |
} | |
}; | |
return { | |
getState: () => ({ | |
...defaultOpts, | |
...options | |
}), | |
createStore: () => ({}) | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment