Answer the question
In order to leave comments, you need to log in
Why, when testing sagas, there are errors of lack of data in the sagas themselves?
There is a saga
export const getQueryUserSaga = function * () {
while (true) {
let {payload} = yield take(GET_QUERY_USERS_REQUEST)
const filtersAll = yield select(filtersSelector)
let filters = null
filtersAll.filter(i => Object.getOwnPropertyNames(i)[0] === moduleName).map(item => filters = item[moduleName])
...
describe('users sagas', () => {
test('look on a default offset users at list', () => {
const sagaGetUsers = getQueryUserSaga()
expect(sagaGetUsers.next().value).toEqual(take(GET_QUERY_USERS_REQUEST))
expect(sagaGetUsers.next().value).toEqual(select(filtersSelector))
})
})
Answer the question
In order to leave comments, you need to log in
Found the answer.
You need to define payload and send the value as a parameter to, sagaGetUsers.next()
for example
describe('users sagas', () => {
test('look on a default offset users at list', () => {
const sagaGetUsers = getQueryUserSaga()
const payload = 'default_filter=none'
expect(sagaGetUsers.next(payload).value).toEqual(take(GET_QUERY_USERS_REQUEST))
expect(sagaGetUsers.next().value).toEqual(select(filtersSelector))
})
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question