diff --git a/packages/amazon-cognito-identity-js/index.d.ts b/packages/amazon-cognito-identity-js/index.d.ts index 62ab9a1ad8f..a82000c35c3 100644 --- a/packages/amazon-cognito-identity-js/index.d.ts +++ b/packages/amazon-cognito-identity-js/index.d.ts @@ -100,7 +100,7 @@ declare module 'amazon-cognito-identity-js' { clientMetaData?: ClientMetadata ): void; public resendConfirmationCode( - callback: NodeCallback, + callback: NodeCallback, clientMetaData?: ClientMetadata ): void; public changePassword( diff --git a/packages/auth/__tests__/auth-unit-test.ts b/packages/auth/__tests__/auth-unit-test.ts index 05ac58c210f..14984a249a7 100644 --- a/packages/auth/__tests__/auth-unit-test.ts +++ b/packages/auth/__tests__/auth-unit-test.ts @@ -139,7 +139,13 @@ jest.mock('amazon-cognito-identity-js/lib/CognitoUser', () => { }; CognitoUser.prototype.resendConfirmationCode = callback => { - callback(null, 'result'); + callback(null, { + CodeDeliveryDetails: { + AttributeName: 'email', + DeliveryMedium: 'EMAIL', + Destination: 'amplify@*****.com', + }, + }); }; CognitoUser.prototype.changePassword = ( @@ -611,7 +617,13 @@ describe('auth unit test', () => { const auth = new Auth(authOptions); expect.assertions(1); - expect(await auth.resendSignUp('username')).toBe('result'); + expect(await auth.resendSignUp('username')).toMatchObject({ + CodeDeliveryDetails: { + AttributeName: 'email', + DeliveryMedium: 'EMAIL', + Destination: 'amplify@*****.com', + }, + }); spyon.mockClear(); }); diff --git a/packages/auth/src/Auth.ts b/packages/auth/src/Auth.ts index 1b18173fc2c..d518e35562f 100644 --- a/packages/auth/src/Auth.ts +++ b/packages/auth/src/Auth.ts @@ -379,12 +379,12 @@ export class AuthClass { * Resend the verification code * @param {String} username - The username to be confirmed * @param {ClientMetadata} clientMetadata - Metadata to be passed to Cognito Lambda triggers - * @return - A promise resolves data if success + * @return - A promise resolves code delivery details if successful */ public resendSignUp( username: string, clientMetadata: ClientMetaData = this._config.clientMetadata - ): Promise { + ): Promise { if (!this.userPool) { return this.rejectNoUserPool(); }