You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, first of all thank you for taking the time to create and release this package. Saved a lot of time for me.
Question
How to test a race in redux-saga
Saga code
// Render a simple custom alert view with OK and CANCEL buttons
yield put(SettingsActions.alertView.showAlertView());
// Wait for user to interact with one of the buttons before saga continues
const { alertAction } = yield race({
alertAction: take(SettingsActionTypes.alertView.ON_ACTION_TRIGGERED),
});
// User interacted with either OK or CANCEL so take appropriate action (save relevant prefs)
switch (alertAction.payload) {
case SettingsFieldTypes.alertView.type.CONFIRM:
yield put(RealmActions.saveUser(**with OK setting**));
break;
default:
yield put(RealmActions.saveUser(**with CANCEL setting**));
break;
}
Saga test
// Test if an alert is getting trigger
it('should call an AlertView', (result) => {
expect(result).toEqual(put(SettingsActions.alertView.showAlertView()));
});
// Test if a race is getting called?
it('should wait for AlertView action triggered', (result) => {
expect(result).toEqual(race({
alertAction: take(SettingsActionTypes.alertView.ON_ACTION_TRIGGERED),
}));
});
// Up to here it's fine, but after this point how do I test the saga?
// In actuality, we wait for user to tap on OK, or CANCEL before continuing with the saga
// But how do I simulate that
The text was updated successfully, but these errors were encountered:
Hi, first of all thank you for taking the time to create and release this package. Saved a lot of time for me.
Question
How to test a race in redux-saga
Saga code
Saga test
The text was updated successfully, but these errors were encountered: