diff --git a/src/modules/profile/sagas.spec.ts b/src/modules/profile/sagas.spec.ts index 2f13b741..7e6465b6 100644 --- a/src/modules/profile/sagas.spec.ts +++ b/src/modules/profile/sagas.spec.ts @@ -18,11 +18,12 @@ import { setProfileAvatarDescriptionRequest, setProfileAvatarDescriptionSuccess } from './actions' +import { getIdentityOrRedirect } from '../identity/sagas' +import { call } from 'redux-saga/effects' let mockAuthIdentity: AuthIdentity | undefined = {} as AuthIdentity const profileSagas = createProfileSaga({ - getIdentity: () => mockAuthIdentity, peerUrl: 'aURL' }) const address = 'anAddress' @@ -58,7 +59,8 @@ describe('when handling the action to set the profile avatar description', () => EntitiesOperator.prototype.deployEntityWithoutNewFiles ), Promise.reject(new Error(errorMessage)) - ] + ], + [call(getIdentityOrRedirect), mockAuthIdentity] ]) .put(setProfileAvatarDescriptionFailure(address, errorMessage)) .dispatch(setProfileAvatarDescriptionRequest(address, description)) @@ -83,6 +85,7 @@ describe('when handling the action to set the profile avatar description', () => return expectSaga(profileSagas) .provide([ + [call(getIdentityOrRedirect), mockAuthIdentity], [ matchers.call.fn(PeerAPI.prototype.fetchProfile), dynamicDeepParametersEquality( @@ -166,6 +169,7 @@ describe('when handling the action to set the profile avatar alias', () => { it('should dispatch an action to signal that the request failed', () => { return expectSaga(profileSagas) .provide([ + [call(getIdentityOrRedirect), mockAuthIdentity], [ matchers.call.fn(PeerAPI.prototype.fetchProfile), Promise.resolve(profileFromLambda) @@ -201,6 +205,7 @@ describe('when handling the action to set the profile avatar alias', () => { return expectSaga(profileSagas) .provide([ + [call(getIdentityOrRedirect), mockAuthIdentity], [ matchers.call.fn(PeerAPI.prototype.fetchProfile), dynamicDeepParametersEquality( diff --git a/src/modules/profile/sagas.ts b/src/modules/profile/sagas.ts index e367a980..e1fb0efd 100644 --- a/src/modules/profile/sagas.ts +++ b/src/modules/profile/sagas.ts @@ -4,6 +4,7 @@ import { Avatar } from '@dcl/schemas/dist/platform/profile' import { EntityType } from '@dcl/schemas/dist/platform/entity' import { PeerAPI } from '../../lib/peer' import { EntitiesOperator } from '../../lib/entities' +import { getIdentityOrRedirect } from '../identity/sagas' import { ConnectWalletSuccessAction, CONNECT_WALLET_SUCCESS, @@ -31,13 +32,11 @@ import { Profile } from './types' export const NO_IDENTITY_FOUND_ERROR_MESSAGE = 'No identity found' type CreateProfileSagaOptions = { - getIdentity: () => AuthIdentity | undefined peerUrl: string peerWithNoGbCollectorUrl?: string } export function createProfileSaga({ - getIdentity, peerUrl, peerWithNoGbCollectorUrl }: CreateProfileSagaOptions) { @@ -139,7 +138,7 @@ export function createProfileSaga({ const profileMetadata: Profile = { avatars: [newAvatar, ...profileWithContentHashes.avatars.slice(1)] } - const identity = getIdentity() + const identity: AuthIdentity | null = yield call(getIdentityOrRedirect) if (identity) { yield call(