function* createAccessToken(refreshToken?: string) {
yield put(setAuthenticationStepAction(AuthenticationSteps.CreatingAccessToken));
try {
if (!refreshToken) {
throw new Error('Tried to createAccessToken without a refresh token');
}
// the code is OK until here and also runs inside the call
const response = yield* call(() =>
HeliosApi.createAccessToken(overrideHeliosAuthentication(refreshToken)),
);
// from here we get nothing back into the response and the saga is terminated by timeout
const access_token = response.data.data?.access_token;
const creation_token = response.data.data?.creation_token;
if (access_token) {
setHeliosAccessToken(access_token);
yield put(refreshRiderAction());
} else if (creation_token) {
yield put(setCreationTokenAction(creation_token));
} else {
throw new Error('createAccessToken failed to return any tokens');
}
} catch (error) {
yield createErrorReport('createAccessToken failed', { error });
const status = error.response?.status;
if (status === 404 || status === 401) {
// The refresh token we have is invalid, the user is effectively logged out so do it
yield put(logoutAction());
} else {
yield put(setAuthenticationStepAction(AuthenticationSteps.LoginFailed));
}
}
}
I wanted to know how should I properly call the matchers to actually meet what my api is doing. I think I am not providing it the correct way. I wanted to have those last 2 params inside the call to be nested params. Any ideas? This happens a lot on my sagas and I wanted to test them :)
Howdy everyone! I may be doing things the wrong way but I wanted to ask anyway in case anyone else got the same problem.
Heres my test:
and here is the saga:
I wanted to know how should I properly call the matchers to actually meet what my api is doing. I think I am not providing it the correct way. I wanted to have those last 2 params inside the call to be nested params. Any ideas? This happens a lot on my sagas and I wanted to test them :)
Thanks!