В саге есть несколько путов.
export function* changeItemsSaga(action) {
const prerequisite1 = yield select(prerequisite1Selector);
// some processing
yield put(actions.myAction1(payload1));
// some more processing
const prerequisite2 = yield select(prerequisite2Selector);
// some more processing
yield put(actions.myAction2(payload2));
}
Как мне записать свои ожидания на путы, когда сага возвращает несколько эффектов?
it('should update items', () =>
expectSaga(sagas.changeItemsSaga, action)
.provide([
[select(prerequisite1), {}],
[select(prerequisite2), {}],
])
.put([actions.myAction1(payload1), actions.myAction2(payload2)])
.run());
В модульном тесте ExpectSaga возвращается следующая ошибка:
Saga test error:
put expectation unmet:
Expected
--------
{ channel: null,
action:
[ { type: 'MY_ACTION_1',
payload: { myItem1: [Object] } },
{ type: 'MY_ACTION_2',
payload: { itemCollection: [Object] } } ] }
Actual:
------
1. { channel: null,
action:
{ type: 'MY_ACTION_1',
payload:
{ myItem1:
{ index: 0,
childItem1: [Object],
childItem2: [Object] } } } }
2. { channel: null,
action:
{ type: 'MY_ACTION_2',
payload: { itemCollection: [ [Object] ] } } }
Этот тоже не работает.
it('should update items', () =>
expectSaga(sagas.changeItemsSaga, action)
.provide([
[select(prerequisite1), {}],
[select(prerequisite2), {}],
])
.put(actions.myAction1(payload1))
.put(actions.myAction2(payload2))
.run());
Возвращает эту ошибку.
Saga test error:
put expectation unmet:
Expected
--------
{ channel: null,
action:
{ type: 'MY_ACTION_1',
payload:
{ myItem1:
{ index: 0,
childItem1: [Object],
childItem2: [Object] } } } }
Actual:
------
1. { channel: null,
action:
{ type: 'MY_ACTION_1',
payload:
{ myItem1:
{ index: 0,
childItem1: [Object],
childItem2: [Object] } } } }
2. { channel: null,
action:
{ type: 'MY_ACTION_2',
payload: { itemCollection: [ [Object] ] } } }