@@ -75,7 +75,7 @@ describe('core/credentials/email', () => {
75
75
} ) ;
76
76
77
77
describe ( '#_getIdTokenResponse' , ( ) => {
78
- it ( 'call sign in with password' , async ( ) => {
78
+ it ( 'calls sign in with password' , async ( ) => {
79
79
const idTokenResponse = await credential . _getIdTokenResponse ( auth ) ;
80
80
expect ( idTokenResponse . idToken ) . to . eq ( 'id-token' ) ;
81
81
expect ( idTokenResponse . refreshToken ) . to . eq ( 'refresh-token' ) ;
@@ -90,18 +90,40 @@ describe('core/credentials/email', () => {
90
90
} ) ;
91
91
92
92
describe ( '#_linkToIdToken' , ( ) => {
93
- it ( 'throws' , async ( ) => {
94
- await expect (
95
- credential . _linkToIdToken ( auth , 'id-token' )
96
- ) . to . be . rejectedWith ( Error ) ;
93
+ it ( 'calls update email password' , async ( ) => {
94
+ apiMock = mockEndpoint ( Endpoint . SET_ACCOUNT_INFO , {
95
+ idToken : 'id-token' ,
96
+ refreshToken : 'refresh-token' ,
97
+ expiresIn : '1234' ,
98
+ localId : serverUser . localId !
99
+ } ) ;
100
+
101
+ const idTokenResponse = await credential . _linkToIdToken ( auth , 'id-token-2' ) ;
102
+ expect ( idTokenResponse . idToken ) . to . eq ( 'id-token' ) ;
103
+ expect ( idTokenResponse . refreshToken ) . to . eq ( 'refresh-token' ) ;
104
+ expect ( idTokenResponse . expiresIn ) . to . eq ( '1234' ) ;
105
+ expect ( idTokenResponse . localId ) . to . eq ( serverUser . localId ) ;
106
+ expect ( apiMock . calls [ 0 ] . request ) . to . eql ( {
107
+ idToken : 'id-token-2' ,
108
+ returnSecureToken : true ,
109
+ email : 'some-email' ,
110
+ password : 'some-password'
111
+ } ) ;
97
112
} ) ;
98
113
} ) ;
99
114
100
115
describe ( '#_getReauthenticationResolver' , ( ) => {
101
- it ( 'throws' , ( ) => {
102
- expect ( ( ) => credential . _getReauthenticationResolver ( auth ) ) . to . throw (
103
- Error
104
- ) ;
116
+ it ( 'calls sign in with password' , async ( ) => {
117
+ const idTokenResponse = await credential . _getIdTokenResponse ( auth ) ;
118
+ expect ( idTokenResponse . idToken ) . to . eq ( 'id-token' ) ;
119
+ expect ( idTokenResponse . refreshToken ) . to . eq ( 'refresh-token' ) ;
120
+ expect ( idTokenResponse . expiresIn ) . to . eq ( '1234' ) ;
121
+ expect ( idTokenResponse . localId ) . to . eq ( serverUser . localId ) ;
122
+ expect ( apiMock . calls [ 0 ] . request ) . to . eql ( {
123
+ returnSecureToken : true ,
124
+ email : 'some-email' ,
125
+ password : 'some-password'
126
+ } ) ;
105
127
} ) ;
106
128
} ) ;
107
129
} ) ;
@@ -153,18 +175,31 @@ describe('core/credentials/email', () => {
153
175
} ) ;
154
176
155
177
describe ( '#_linkToIdToken' , ( ) => {
156
- it ( 'throws' , async ( ) => {
157
- await expect (
158
- credential . _linkToIdToken ( auth , 'id-token' )
159
- ) . to . be . rejectedWith ( Error ) ;
178
+ it ( 'calls sign in with the new token' , async ( ) => {
179
+ const idTokenResponse = await credential . _linkToIdToken ( auth , 'id-token-2' ) ;
180
+ expect ( idTokenResponse . idToken ) . to . eq ( 'id-token' ) ;
181
+ expect ( idTokenResponse . refreshToken ) . to . eq ( 'refresh-token' ) ;
182
+ expect ( idTokenResponse . expiresIn ) . to . eq ( '1234' ) ;
183
+ expect ( idTokenResponse . localId ) . to . eq ( serverUser . localId ) ;
184
+ expect ( apiMock . calls [ 0 ] . request ) . to . eql ( {
185
+ idToken : 'id-token-2' ,
186
+ email : 'some-email' ,
187
+ oobCode : 'oob-code'
188
+ } ) ;
160
189
} ) ;
161
190
} ) ;
162
191
163
192
describe ( '#_matchIdTokenWithUid' , ( ) => {
164
- it ( 'throws' , ( ) => {
165
- expect ( ( ) => credential . _getReauthenticationResolver ( auth ) ) . to . throw (
166
- Error
167
- ) ;
193
+ it ( 'call sign in with email link' , async ( ) => {
194
+ const idTokenResponse = await credential . _getIdTokenResponse ( auth ) ;
195
+ expect ( idTokenResponse . idToken ) . to . eq ( 'id-token' ) ;
196
+ expect ( idTokenResponse . refreshToken ) . to . eq ( 'refresh-token' ) ;
197
+ expect ( idTokenResponse . expiresIn ) . to . eq ( '1234' ) ;
198
+ expect ( idTokenResponse . localId ) . to . eq ( serverUser . localId ) ;
199
+ expect ( apiMock . calls [ 0 ] . request ) . to . eql ( {
200
+ email : 'some-email' ,
201
+ oobCode : 'oob-code'
202
+ } ) ;
168
203
} ) ;
169
204
} ) ;
170
205
} ) ;
0 commit comments