Open vandiepbui opened 3 years ago
Hi,
I have a callback function in payload. Please tell me how to call that callback function when testSaga.
My saga.js export const sumTwoNumbers = function* ({ payload: { a, b, onSuccess } }) { try { let sum = a + b; yield put(sumTwoNumbersSuccess()); yield call(onSuccess(sum)); } catch(e) { console.log(e) } };
My saga.test.js
describe('sum two numbers', () => { const actionPayload = { type: 'SUM_TWO_NUMBER', payload: { a: 5, b: 6, onSuccess: () => 11, }, };
it('should sum two numbers success', () => { testSaga(sumTwoNumbers, actionPayload) .next() .put(sumTwoNumbersSuccess()) .next() .isDone(); }); });
I want to call onSuccess function in unit test. Please help me! Thanks so much!
Hi,
I have a callback function in payload. Please tell me how to call that callback function when testSaga.
My saga.js export const sumTwoNumbers = function* ({ payload: { a, b, onSuccess } }) { try { let sum = a + b; yield put(sumTwoNumbersSuccess()); yield call(onSuccess(sum)); } catch(e) { console.log(e) } };
My saga.test.js
describe('sum two numbers', () => { const actionPayload = { type: 'SUM_TWO_NUMBER', payload: { a: 5, b: 6, onSuccess: () => 11, }, };
it('should sum two numbers success', () => { testSaga(sumTwoNumbers, actionPayload) .next() .put(sumTwoNumbersSuccess()) .next() .isDone(); }); });
I want to call onSuccess function in unit test. Please help me! Thanks so much!