Testing redux-saga with conventional means is a pretty nasty business. You should use redux-saga-test-plan I highly recommend it, its very good
So, I dont see the saga you want to test, but seeing, that you want to mock
.call() lets take it as an example. I think that if you understand this, you wont have problems understanding the other features of redux-saga.
function* userSaga(api) {
const user = yield call(api.fetchUser, action.payload);
yield put({
type: 'RECEIVE_USER',
payload: { user, pet },
});
}
it('fetches the user', () => {
const fakeUser = { name: 'Jeremy', petId: 20 };
const fakeDog = { name: 'Tucker' };
return expectSaga(userSaga, api)
.provide([
[call(api.fetchUser, 42), fakeUser],
])
.put({
type: 'RECEIVE_USER',
payload: { user: fakeUser, pet: fakeDog },
})
.run();
});
Notice how we pass an array with the call we want to simulate and the result we want to mock. You can do that with select too.
Put is also very intuitive, your test will expect the saga to fire this action.
There are other stuff, which are really beneficial like
.withReducer(reducer)
.hasFinalState({
name: 'Tucker',
age: 12,
})
This way you set a reducer with an initial state of your choice. After all the effects get fired according to your test requirements, redux-saga-test-plan will check if the reducer has changed accordingly.