recoil#MutableSnapshot TypeScript Examples
The following examples show how to use
recoil#MutableSnapshot.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: render-helper.tsx From clean-react with GNU General Public License v3.0 | 6 votes |
renderWithHistory = ({ Page, history, account = mockAccountModel(), states = [] }: Params): Result => {
const setCurrentAccountMock = jest.fn()
const mockedState = {
setCurrentAccount: setCurrentAccountMock,
getCurrentAccount: () => account
}
const initializeState = ({ set }: MutableSnapshot): void => {
[...states, { atom: currentAccountState, value: mockedState }].forEach(state => set(state.atom, state.value))
}
render(
<RecoilRoot initializeState={initializeState}>
<Router history={history}>
<Page />
</Router>
</RecoilRoot>
)
return {
setCurrentAccountMock
}
}