@@ -2869,10 +2869,12 @@ AUTH_CONFIGS.forEach((testConfig) => {
28692869 { api : 'generatePasswordResetLink' , requestType : 'PASSWORD_RESET' , requiresSettings : false } ,
28702870 { api : 'generateEmailVerificationLink' , requestType : 'VERIFY_EMAIL' , requiresSettings : false } ,
28712871 { api : 'generateSignInWithEmailLink' , requestType : 'EMAIL_SIGNIN' , requiresSettings : true } ,
2872+ { api : 'generateVerifyAndChangeEmailLink' , requestType : 'VERIFY_AND_CHANGE_EMAIL' , requiresSettings : false } ,
28722873 ] ;
28732874 emailActionFlows . forEach ( ( emailActionFlow ) => {
28742875 describe ( `${ emailActionFlow . api } ()` , ( ) => {
28752876 const email = '[email protected] ' ; 2877+ const newEmail = '[email protected] ' ; 28762878 const actionCodeSettings = {
28772879 url : 'https://www.example.com/path/file?a=1&b=2' ,
28782880 handleCodeInApp : true ,
@@ -2898,32 +2900,71 @@ AUTH_CONFIGS.forEach((testConfig) => {
28982900 } ) ;
28992901
29002902 it ( 'should be rejected given no email' , ( ) => {
2901- return ( auth as any ) [ emailActionFlow . api ] ( undefined , actionCodeSettings )
2903+ let args : any = [ undefined , actionCodeSettings ] ;
2904+ if ( emailActionFlow . api === 'generateVerifyAndChangeEmailLink' ) {
2905+ args = [ undefined , newEmail , actionCodeSettings ] ;
2906+ }
2907+ return ( auth as any ) [ emailActionFlow . api ] ( ...args )
29022908 . should . eventually . be . rejected . and . have . property ( 'code' , 'auth/invalid-email' ) ;
29032909 } ) ;
29042910
29052911 it ( 'should be rejected given an invalid email' , ( ) => {
2906- return ( auth as any ) [ emailActionFlow . api ] ( 'invalid' , actionCodeSettings )
2912+ let args : any = [ 'invalid' , actionCodeSettings ] ;
2913+ if ( emailActionFlow . api === 'generateVerifyAndChangeEmailLink' ) {
2914+ args = [ 'invalid' , newEmail , actionCodeSettings ] ;
2915+ }
2916+ return ( auth as any ) [ emailActionFlow . api ] ( ...args )
29072917 . should . eventually . be . rejected . and . have . property ( 'code' , 'auth/invalid-email' ) ;
29082918 } ) ;
29092919
2920+ it ( 'should be rejected given no new email when request type is `generateVerifyAndChangeEmailLink`' , ( ) => {
2921+ if ( emailActionFlow . api === 'generateVerifyAndChangeEmailLink' ) {
2922+ return ( auth as any ) [ emailActionFlow . api ] ( email )
2923+ . should . eventually . be . rejected . and . have . property ( 'code' , 'auth/argument-error' ) ;
2924+ }
2925+ } ) ;
2926+
2927+ it ( 'should be rejected given an invalid new email when request type is `generateVerifyAndChangeEmailLink`' ,
2928+ ( ) => {
2929+ if ( emailActionFlow . api === 'generateVerifyAndChangeEmailLink' ) {
2930+ return ( auth as any ) [ emailActionFlow . api ] ( email , 'invalid' )
2931+ . should . eventually . be . rejected . and . have . property ( 'code' , 'auth/invalid-new-email' ) ;
2932+ }
2933+ } ) ;
2934+
29102935 it ( 'should be rejected given an invalid ActionCodeSettings object' , ( ) => {
2911- return ( auth as any ) [ emailActionFlow . api ] ( email , 'invalid' )
2936+ let args : any = [ email , 'invalid' ] ;
2937+ if ( emailActionFlow . api === 'generateVerifyAndChangeEmailLink' ) {
2938+ args = [ email , newEmail , 'invalid' ] ;
2939+ }
2940+ return ( auth as any ) [ emailActionFlow . api ] ( ...args )
29122941 . should . eventually . be . rejected . and . have . property ( 'code' , 'auth/argument-error' ) ;
29132942 } ) ;
29142943
29152944 it ( 'should be rejected given an app which returns null access tokens' , ( ) => {
2916- return ( nullAccessTokenAuth as any ) [ emailActionFlow . api ] ( email , actionCodeSettings )
2945+ let args : any = [ email , actionCodeSettings ] ;
2946+ if ( emailActionFlow . api === 'generateVerifyAndChangeEmailLink' ) {
2947+ args = [ email , newEmail , actionCodeSettings ] ;
2948+ }
2949+ return ( nullAccessTokenAuth as any ) [ emailActionFlow . api ] ( ...args )
29172950 . should . eventually . be . rejected . and . have . property ( 'code' , 'app/invalid-credential' ) ;
29182951 } ) ;
29192952
29202953 it ( 'should be rejected given an app which returns invalid access tokens' , ( ) => {
2921- return ( malformedAccessTokenAuth as any ) [ emailActionFlow . api ] ( email , actionCodeSettings )
2954+ let args : any = [ email , actionCodeSettings ] ;
2955+ if ( emailActionFlow . api === 'generateVerifyAndChangeEmailLink' ) {
2956+ args = [ email , newEmail , actionCodeSettings ] ;
2957+ }
2958+ return ( malformedAccessTokenAuth as any ) [ emailActionFlow . api ] ( ...args )
29222959 . should . eventually . be . rejected . and . have . property ( 'code' , 'app/invalid-credential' ) ;
29232960 } ) ;
29242961
29252962 it ( 'should be rejected given an app which fails to generate access tokens' , ( ) => {
2926- return ( rejectedPromiseAccessTokenAuth as any ) [ emailActionFlow . api ] ( email , actionCodeSettings )
2963+ let args : any = [ email , actionCodeSettings ] ;
2964+ if ( emailActionFlow . api === 'generateVerifyAndChangeEmailLink' ) {
2965+ args = [ email , newEmail , actionCodeSettings ] ;
2966+ }
2967+ return ( rejectedPromiseAccessTokenAuth as any ) [ emailActionFlow . api ] ( ...args )
29272968 . should . eventually . be . rejected . and . have . property ( 'code' , 'app/invalid-credential' ) ;
29282969 } ) ;
29292970
@@ -2932,7 +2973,11 @@ AUTH_CONFIGS.forEach((testConfig) => {
29322973 const getEmailActionLinkStub = sinon . stub ( testConfig . RequestHandler . prototype , 'getEmailActionLink' )
29332974 . resolves ( expectedLink ) ;
29342975 stubs . push ( getEmailActionLinkStub ) ;
2935- return ( auth as any ) [ emailActionFlow . api ] ( email , actionCodeSettings )
2976+ let args : any = [ email , actionCodeSettings ] ;
2977+ if ( emailActionFlow . api === 'generateVerifyAndChangeEmailLink' ) {
2978+ args = [ email , newEmail , actionCodeSettings ] ;
2979+ }
2980+ return ( auth as any ) [ emailActionFlow . api ] ( ...args )
29362981 . then ( ( actualLink : string ) => {
29372982 // Confirm underlying API called with expected parameters.
29382983 expect ( getEmailActionLinkStub ) . to . have . been . calledOnce . and . calledWith (
@@ -2953,7 +2998,11 @@ AUTH_CONFIGS.forEach((testConfig) => {
29532998 const getEmailActionLinkStub = sinon . stub ( testConfig . RequestHandler . prototype , 'getEmailActionLink' )
29542999 . resolves ( expectedLink ) ;
29553000 stubs . push ( getEmailActionLinkStub ) ;
2956- return ( auth as any ) [ emailActionFlow . api ] ( email )
3001+ let args : any = [ email ] ;
3002+ if ( emailActionFlow . api === 'generateVerifyAndChangeEmailLink' ) {
3003+ args = [ email , newEmail ] ;
3004+ }
3005+ return ( auth as any ) [ emailActionFlow . api ] ( ...args )
29573006 . then ( ( actualLink : string ) => {
29583007 // Confirm underlying API called with expected parameters.
29593008 expect ( getEmailActionLinkStub ) . to . have . been . calledOnce . and . calledWith (
@@ -2969,7 +3018,11 @@ AUTH_CONFIGS.forEach((testConfig) => {
29693018 const getEmailActionLinkStub = sinon . stub ( testConfig . RequestHandler . prototype , 'getEmailActionLink' )
29703019 . rejects ( expectedError ) ;
29713020 stubs . push ( getEmailActionLinkStub ) ;
2972- return ( auth as any ) [ emailActionFlow . api ] ( email , actionCodeSettings )
3021+ let args : any = [ email , actionCodeSettings ] ;
3022+ if ( emailActionFlow . api === 'generateVerifyAndChangeEmailLink' ) {
3023+ args = [ email , newEmail , actionCodeSettings ] ;
3024+ }
3025+ return ( auth as any ) [ emailActionFlow . api ] ( ...args )
29733026 . then ( ( ) => {
29743027 throw new Error ( 'Unexpected success' ) ;
29753028 } , ( error : any ) => {
0 commit comments