Created
March 14, 2018 18:22
-
-
Save HigoRibeiro/dbdcf667c75e3bb5d9b5226e3d2e1ed6 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
/* Core */ | |
import SagaTester from 'redux-saga-tester'; | |
import MockAdapter from 'axios-mock-adapter'; | |
/* redux */ | |
import configureStore from 'redux-mock-store'; | |
import rootSaga from 'store/sagas'; | |
import api from 'services/api'; | |
import ActionCreators from 'store/ducks/user'; | |
import { NavigationActions } from 'react-navigation'; | |
const userFixture = require('./fixtures/user.json'); | |
const mockStore = configureStore([]); | |
describe('Testing User Saga', () => { | |
let sagaTester = null; | |
let apiMock = null; | |
const store = mockStore({}); | |
beforeEach(() => { | |
sagaTester = new SagaTester({}); | |
apiMock = new MockAdapter(api.axiosInstance); | |
sagaTester.start(rootSaga); | |
store.clearActions(); | |
}); | |
it('Can get user information', async () => { | |
apiMock.onGet('/api/user/9999999999') | |
.reply(userFixture['/api/user/9999999999']); | |
sagaTester.dispatch(ActionCreators.userGetInformation('9999999999')); | |
//console.log(NavigationActions.navigate({ routeName: 'SignIn' })); | |
// await sagaTester.waitFor(NavigationActions.navigate({ routeName: 'SignIn' }).type); | |
store.dispatch(NavigationActions.navigate({ routeName: 'SignIn' })); | |
const actions = store.getActions(); | |
console.log(actions); | |
console.log(sagaTester.getCalledActions()); | |
console.log(sagaTester.getLatestCalledActions()); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment