@@ -65,35 +65,44 @@ describe('core/user/profile', () => {
65
65
} ) ;
66
66
67
67
it ( 'calls the setAccountInfo endpoint' , async ( ) => {
68
- const ep = mockEndpoint ( Endpoint . SET_ACCOUNT_INFO , { } ) ;
68
+ const ep = mockEndpoint ( Endpoint . SET_ACCOUNT_INFO , { } ) ;
69
69
70
- await updateProfile ( user , { displayName : 'displayname' , photoURL : 'photo' } ) ;
70
+ await updateProfile ( user , {
71
+ displayName : 'displayname' ,
72
+ photoURL : 'photo'
73
+ } ) ;
71
74
expect ( ep . calls [ 0 ] . request ) . to . eql ( {
72
75
idToken : 'access-token' ,
73
76
displayName : 'displayname' ,
74
- photoUrl : 'photo' ,
77
+ photoUrl : 'photo'
75
78
} ) ;
76
79
} ) ;
77
80
78
81
it ( 'sets the fields on the user based on the response' , async ( ) => {
79
82
mockEndpoint ( Endpoint . SET_ACCOUNT_INFO , {
80
83
displayName : 'response-name' ,
81
- photoUrl : 'response-photo' ,
84
+ photoUrl : 'response-photo'
82
85
} ) ;
83
86
84
- await updateProfile ( user , { displayName : 'displayname' , photoURL : 'photo' } ) ;
87
+ await updateProfile ( user , {
88
+ displayName : 'displayname' ,
89
+ photoURL : 'photo'
90
+ } ) ;
85
91
expect ( user . displayName ) . to . eq ( 'response-name' ) ;
86
92
expect ( user . photoURL ) . to . eq ( 'response-photo' ) ;
87
93
} ) ;
88
94
89
95
it ( 'sets the fields on the password provider' , async ( ) => {
90
96
mockEndpoint ( Endpoint . SET_ACCOUNT_INFO , {
91
97
displayName : 'response-name' ,
92
- photoUrl : 'response-photo' ,
98
+ photoUrl : 'response-photo'
93
99
} ) ;
94
- user . providerData = [ { ...PASSWORD_PROVIDER } ] ;
100
+ user . providerData = [ { ...PASSWORD_PROVIDER } ] ;
95
101
96
- await updateProfile ( user , { displayName : 'displayname' , photoURL : 'photo' } ) ;
102
+ await updateProfile ( user , {
103
+ displayName : 'displayname' ,
104
+ photoURL : 'photo'
105
+ } ) ;
97
106
const provider = user . providerData [ 0 ] ;
98
107
expect ( provider . displayName ) . to . eq ( 'response-name' ) ;
99
108
expect ( provider . photoURL ) . to . eq ( 'response-photo' ) ;
@@ -103,14 +112,14 @@ describe('core/user/profile', () => {
103
112
describe ( '#updateEmail' , ( ) => {
104
113
it ( 'calls the setAccountInfo endpoint and reloads the user' , async ( ) => {
105
114
const set = mockEndpoint ( Endpoint . SET_ACCOUNT_INFO , { } ) ;
106
- mockEndpoint ( Endpoint . GET_ACCOUNT_INFO , { users : [
107
- { localId : 'new-uid-to-prove-refresh-got-called' } ,
108
- ] } ) ;
115
+ mockEndpoint ( Endpoint . GET_ACCOUNT_INFO , {
116
+ users : [ { localId : 'new-uid-to-prove-refresh-got-called' } ]
117
+ } ) ;
109
118
110
119
await updateEmail ( user , '[email protected] ' ) ;
111
120
expect ( set . calls [ 0 ] . request ) . to . eql ( {
112
121
idToken : 'access-token' ,
113
-
122
+
114
123
} ) ;
115
124
116
125
expect ( user . uid ) . to . eq ( 'new-uid-to-prove-refresh-got-called' ) ;
@@ -120,14 +129,14 @@ describe('core/user/profile', () => {
120
129
describe ( '#updatePassword' , ( ) => {
121
130
it ( 'calls the setAccountInfo endpoint and reloads the user' , async ( ) => {
122
131
const set = mockEndpoint ( Endpoint . SET_ACCOUNT_INFO , { } ) ;
123
- mockEndpoint ( Endpoint . GET_ACCOUNT_INFO , { users : [
124
- { localId : 'new-uid-to-prove-refresh-got-called' } ,
125
- ] } ) ;
132
+ mockEndpoint ( Endpoint . GET_ACCOUNT_INFO , {
133
+ users : [ { localId : 'new-uid-to-prove-refresh-got-called' } ]
134
+ } ) ;
126
135
127
136
await updatePassword ( user , 'pass' ) ;
128
137
expect ( set . calls [ 0 ] . request ) . to . eql ( {
129
138
idToken : 'access-token' ,
130
- password : 'pass' ,
139
+ password : 'pass'
131
140
} ) ;
132
141
133
142
expect ( user . uid ) . to . eq ( 'new-uid-to-prove-refresh-got-called' ) ;
@@ -152,89 +161,101 @@ describe('core/user/profile', () => {
152
161
mockEndpoint ( Endpoint . SET_ACCOUNT_INFO , {
153
162
idToken : 'new-id-token' ,
154
163
refreshToken : 'new-refresh-token' ,
155
- expiresIn : 300 ,
164
+ expiresIn : 300
156
165
} ) ;
157
166
158
- await updateProfile ( user , { displayName : 'd' } ) ;
167
+ await updateProfile ( user , { displayName : 'd' } ) ;
159
168
expect ( idTokenChange ) . to . have . been . called ;
160
- expect ( auth . persistenceLayer . lastObjectSet ) . to . eql ( user . toPlainObject ( ) ) ;
169
+ expect ( auth . persistenceLayer . lastObjectSet ) . to . eql (
170
+ user . toPlainObject ( )
171
+ ) ;
161
172
} ) ;
162
173
163
174
it ( 'does NOT trigger a token update if unnecessary' , async ( ) => {
164
175
mockEndpoint ( Endpoint . SET_ACCOUNT_INFO , {
165
176
idToken : 'access-token' ,
166
177
refreshToken : 'refresh-token' ,
167
- expiresIn : 300 ,
178
+ expiresIn : 300
168
179
} ) ;
169
180
170
- await updateProfile ( user , { displayName : 'd' } ) ;
181
+ await updateProfile ( user , { displayName : 'd' } ) ;
171
182
expect ( idTokenChange ) . not . to . have . been . called ;
172
- expect ( auth . persistenceLayer . lastObjectSet ) . to . eql ( user . toPlainObject ( ) ) ;
183
+ expect ( auth . persistenceLayer . lastObjectSet ) . to . eql (
184
+ user . toPlainObject ( )
185
+ ) ;
173
186
} ) ;
174
187
} ) ;
175
188
176
189
describe ( '#updateEmail' , ( ) => {
177
190
beforeEach ( ( ) => {
178
191
// This is necessary because this method calls reload; we don't care about that though,
179
192
// for these tests we're looking at the change listeners
180
- mockEndpoint ( Endpoint . GET_ACCOUNT_INFO , { users : [ { } ] } ) ;
193
+ mockEndpoint ( Endpoint . GET_ACCOUNT_INFO , { users : [ { } ] } ) ;
181
194
} ) ;
182
195
183
196
it ( 'triggers a token update if necessary' , async ( ) => {
184
197
mockEndpoint ( Endpoint . SET_ACCOUNT_INFO , {
185
198
idToken : 'new-id-token' ,
186
199
refreshToken : 'new-refresh-token' ,
187
- expiresIn : 300 ,
200
+ expiresIn : 300
188
201
} ) ;
189
202
190
203
await updatePassword ( user , '[email protected] ' ) ;
191
204
expect ( idTokenChange ) . to . have . been . called ;
192
- expect ( auth . persistenceLayer . lastObjectSet ) . to . eql ( user . toPlainObject ( ) ) ;
205
+ expect ( auth . persistenceLayer . lastObjectSet ) . to . eql (
206
+ user . toPlainObject ( )
207
+ ) ;
193
208
} ) ;
194
209
195
210
it ( 'does NOT trigger a token update if unnecessary' , async ( ) => {
196
211
mockEndpoint ( Endpoint . SET_ACCOUNT_INFO , {
197
212
idToken : 'access-token' ,
198
213
refreshToken : 'refresh-token' ,
199
- expiresIn : 300 ,
214
+ expiresIn : 300
200
215
} ) ;
201
216
202
217
await updateEmail ( user , '[email protected] ' ) ;
203
218
expect ( idTokenChange ) . not . to . have . been . called ;
204
- expect ( auth . persistenceLayer . lastObjectSet ) . to . eql ( user . toPlainObject ( ) ) ;
219
+ expect ( auth . persistenceLayer . lastObjectSet ) . to . eql (
220
+ user . toPlainObject ( )
221
+ ) ;
205
222
} ) ;
206
223
} ) ;
207
224
208
225
describe ( '#updatePassword' , ( ) => {
209
226
beforeEach ( ( ) => {
210
227
// This is necessary because this method calls reload; we don't care about that though,
211
228
// for these tests we're looking at the change listeners
212
- mockEndpoint ( Endpoint . GET_ACCOUNT_INFO , { users : [ { } ] } ) ;
229
+ mockEndpoint ( Endpoint . GET_ACCOUNT_INFO , { users : [ { } ] } ) ;
213
230
} ) ;
214
231
215
232
it ( 'triggers a token update if necessary' , async ( ) => {
216
233
mockEndpoint ( Endpoint . SET_ACCOUNT_INFO , {
217
234
idToken : 'new-id-token' ,
218
235
refreshToken : 'new-refresh-token' ,
219
- expiresIn : 300 ,
236
+ expiresIn : 300
220
237
} ) ;
221
238
222
239
await updatePassword ( user , 'pass' ) ;
223
240
expect ( idTokenChange ) . to . have . been . called ;
224
- expect ( auth . persistenceLayer . lastObjectSet ) . to . eql ( user . toPlainObject ( ) ) ;
241
+ expect ( auth . persistenceLayer . lastObjectSet ) . to . eql (
242
+ user . toPlainObject ( )
243
+ ) ;
225
244
} ) ;
226
245
227
246
it ( 'does NOT trigger a token update if unnecessary' , async ( ) => {
228
247
mockEndpoint ( Endpoint . SET_ACCOUNT_INFO , {
229
248
idToken : 'access-token' ,
230
249
refreshToken : 'refresh-token' ,
231
- expiresIn : 300 ,
250
+ expiresIn : 300
232
251
} ) ;
233
252
234
253
await updatePassword ( user , 'pass' ) ;
235
254
expect ( idTokenChange ) . not . to . have . been . called ;
236
- expect ( auth . persistenceLayer . lastObjectSet ) . to . eql ( user . toPlainObject ( ) ) ;
255
+ expect ( auth . persistenceLayer . lastObjectSet ) . to . eql (
256
+ user . toPlainObject ( )
257
+ ) ;
237
258
} ) ;
238
259
} ) ;
239
260
} ) ;
240
- } ) ;
261
+ } ) ;
0 commit comments