@@ -20,11 +20,7 @@ import * as chaiAsPromised from 'chai-as-promised';
20
20
import * as sinon from 'sinon' ;
21
21
import * as sinonChai from 'sinon-chai' ;
22
22
23
- import {
24
- OperationType ,
25
- PopupRedirectResolver ,
26
- ProviderId
27
- } from '@firebase/auth-types-exp' ;
23
+ import { OperationType , PopupRedirectResolver , ProviderId } from '@firebase/auth-types-exp' ;
28
24
import { FirebaseError } from '@firebase/util' ;
29
25
30
26
import { delay } from '../../../test/helpers/delay' ;
@@ -43,11 +39,8 @@ import * as eid from '../util/event_id';
43
39
import { AuthPopup } from '../util/popup' ;
44
40
import * as idpTasks from './idp' ;
45
41
import {
46
- _AUTH_EVENT_TIMEOUT ,
47
- _POLL_WINDOW_CLOSE_TIMEOUT ,
48
- linkWithPopup ,
49
- reauthenticateWithPopup ,
50
- signInWithPopup
42
+ _AUTH_EVENT_TIMEOUT , _POLL_WINDOW_CLOSE_TIMEOUT , linkWithPopup , reauthenticateWithPopup ,
43
+ signInWithPopup
51
44
} from './popup' ;
52
45
53
46
use ( sinonChai ) ;
@@ -96,12 +89,11 @@ describe('src/core/strategies/popup', () => {
96
89
97
90
context ( 'signInWithPopup' , ( ) => {
98
91
it ( 'completes the full flow' , async ( ) => {
99
- const cred = new UserCredentialImpl (
100
- testUser ( auth , 'uid' ) ,
101
- ProviderId . GOOGLE ,
102
- undefined ,
103
- OperationType . SIGN_IN
104
- ) ;
92
+ const cred = new UserCredentialImpl ( {
93
+ user : testUser ( auth , 'uid' ) ,
94
+ providerId : ProviderId . GOOGLE ,
95
+ operationType : OperationType . SIGN_IN
96
+ } ) ;
105
97
idpStubs . _signIn . returns ( Promise . resolve ( cred ) ) ;
106
98
const promise = signInWithPopup ( auth , provider , resolver ) ;
107
99
iframeEvent ( {
@@ -111,12 +103,11 @@ describe('src/core/strategies/popup', () => {
111
103
} ) ;
112
104
113
105
it ( 'ignores events for another event id' , async ( ) => {
114
- const cred = new UserCredentialImpl (
115
- testUser ( auth , 'uid' ) ,
116
- ProviderId . GOOGLE ,
117
- undefined ,
118
- OperationType . SIGN_IN
119
- ) ;
106
+ const cred = new UserCredentialImpl ( {
107
+ user : testUser ( auth , 'uid' ) ,
108
+ providerId : ProviderId . GOOGLE ,
109
+ operationType : OperationType . SIGN_IN
110
+ } ) ;
120
111
idpStubs . _signIn . returns ( Promise . resolve ( cred ) ) ;
121
112
const promise = signInWithPopup ( auth , provider , resolver ) ;
122
113
iframeEvent ( {
@@ -137,12 +128,11 @@ describe('src/core/strategies/popup', () => {
137
128
} ) ;
138
129
139
130
it ( 'does not call idp tasks if event is error' , async ( ) => {
140
- const cred = new UserCredentialImpl (
141
- testUser ( auth , 'uid' ) ,
142
- ProviderId . GOOGLE ,
143
- undefined ,
144
- OperationType . SIGN_IN
145
- ) ;
131
+ const cred = new UserCredentialImpl ( {
132
+ user : testUser ( auth , 'uid' ) ,
133
+ providerId : ProviderId . GOOGLE ,
134
+ operationType : OperationType . SIGN_IN
135
+ } ) ;
146
136
idpStubs . _signIn . returns ( Promise . resolve ( cred ) ) ;
147
137
const promise = signInWithPopup ( auth , provider , resolver ) ;
148
138
iframeEvent ( {
@@ -162,12 +152,11 @@ describe('src/core/strategies/popup', () => {
162
152
} ) ;
163
153
164
154
it ( 'does not error if the poll timeout trips' , async ( ) => {
165
- const cred = new UserCredentialImpl (
166
- testUser ( auth , 'uid' ) ,
167
- ProviderId . GOOGLE ,
168
- undefined ,
169
- OperationType . SIGN_IN
170
- ) ;
155
+ const cred = new UserCredentialImpl ( {
156
+ user : testUser ( auth , 'uid' ) ,
157
+ providerId : ProviderId . GOOGLE ,
158
+ operationType : OperationType . SIGN_IN
159
+ } ) ;
171
160
idpStubs . _signIn . returns ( Promise . resolve ( cred ) ) ;
172
161
const promise = signInWithPopup ( auth , provider , resolver ) ;
173
162
delay ( ( ) => {
@@ -181,12 +170,11 @@ describe('src/core/strategies/popup', () => {
181
170
} ) ;
182
171
183
172
it ( 'does error if the poll timeout and event timeout trip' , async ( ) => {
184
- const cred = new UserCredentialImpl (
185
- testUser ( auth , 'uid' ) ,
186
- ProviderId . GOOGLE ,
187
- undefined ,
188
- OperationType . SIGN_IN
189
- ) ;
173
+ const cred = new UserCredentialImpl ( {
174
+ user : testUser ( auth , 'uid' ) ,
175
+ providerId : ProviderId . GOOGLE ,
176
+ operationType : OperationType . SIGN_IN
177
+ } ) ;
190
178
idpStubs . _signIn . returns ( Promise . resolve ( cred ) ) ;
191
179
const promise = signInWithPopup ( auth , provider , resolver ) ;
192
180
delay ( ( ) => {
@@ -224,12 +212,11 @@ describe('src/core/strategies/popup', () => {
224
212
} ) ;
225
213
226
214
it ( 'cancels the task if called consecutively' , async ( ) => {
227
- const cred = new UserCredentialImpl (
228
- testUser ( auth , 'uid' ) ,
229
- ProviderId . GOOGLE ,
230
- undefined ,
231
- OperationType . SIGN_IN
232
- ) ;
215
+ const cred = new UserCredentialImpl ( {
216
+ user : testUser ( auth , 'uid' ) ,
217
+ providerId : ProviderId . GOOGLE ,
218
+ operationType : OperationType . SIGN_IN
219
+ } ) ;
233
220
idpStubs . _signIn . returns ( Promise . resolve ( cred ) ) ;
234
221
const firstPromise = signInWithPopup ( auth , provider , resolver ) ;
235
222
const secondPromise = signInWithPopup ( auth , provider , resolver ) ;
@@ -251,12 +238,11 @@ describe('src/core/strategies/popup', () => {
251
238
} ) ;
252
239
253
240
it ( 'completes the full flow' , async ( ) => {
254
- const cred = new UserCredentialImpl (
241
+ const cred = new UserCredentialImpl ( {
255
242
user,
256
- ProviderId . GOOGLE ,
257
- undefined ,
258
- OperationType . LINK
259
- ) ;
243
+ providerId : ProviderId . GOOGLE ,
244
+ operationType : OperationType . LINK
245
+ } ) ;
260
246
idpStubs . _link . returns ( Promise . resolve ( cred ) ) ;
261
247
const promise = linkWithPopup ( user , provider , resolver ) ;
262
248
iframeEvent ( {
@@ -266,12 +252,11 @@ describe('src/core/strategies/popup', () => {
266
252
} ) ;
267
253
268
254
it ( 'ignores events for another event id' , async ( ) => {
269
- const cred = new UserCredentialImpl (
255
+ const cred = new UserCredentialImpl ( {
270
256
user,
271
- ProviderId . GOOGLE ,
272
- undefined ,
273
- OperationType . LINK
274
- ) ;
257
+ providerId : ProviderId . GOOGLE ,
258
+ operationType : OperationType . LINK
259
+ } ) ;
275
260
idpStubs . _link . returns ( Promise . resolve ( cred ) ) ;
276
261
const promise = linkWithPopup ( user , provider , resolver ) ;
277
262
iframeEvent ( {
@@ -292,12 +277,11 @@ describe('src/core/strategies/popup', () => {
292
277
} ) ;
293
278
294
279
it ( 'does not call idp tasks if event is error' , async ( ) => {
295
- const cred = new UserCredentialImpl (
280
+ const cred = new UserCredentialImpl ( {
296
281
user,
297
- ProviderId . GOOGLE ,
298
- undefined ,
299
- OperationType . LINK
300
- ) ;
282
+ providerId : ProviderId . GOOGLE ,
283
+ operationType : OperationType . LINK
284
+ } ) ;
301
285
idpStubs . _link . returns ( Promise . resolve ( cred ) ) ;
302
286
const promise = linkWithPopup ( user , provider , resolver ) ;
303
287
iframeEvent ( {
@@ -317,12 +301,11 @@ describe('src/core/strategies/popup', () => {
317
301
} ) ;
318
302
319
303
it ( 'does not error if the poll timeout trips' , async ( ) => {
320
- const cred = new UserCredentialImpl (
304
+ const cred = new UserCredentialImpl ( {
321
305
user,
322
- ProviderId . GOOGLE ,
323
- undefined ,
324
- OperationType . LINK
325
- ) ;
306
+ providerId : ProviderId . GOOGLE ,
307
+ operationType : OperationType . LINK
308
+ } ) ;
326
309
idpStubs . _link . returns ( Promise . resolve ( cred ) ) ;
327
310
const promise = linkWithPopup ( user , provider , resolver ) ;
328
311
delay ( ( ) => {
@@ -336,12 +319,11 @@ describe('src/core/strategies/popup', () => {
336
319
} ) ;
337
320
338
321
it ( 'does error if the poll timeout and event timeout trip' , async ( ) => {
339
- const cred = new UserCredentialImpl (
322
+ const cred = new UserCredentialImpl ( {
340
323
user,
341
- ProviderId . GOOGLE ,
342
- undefined ,
343
- OperationType . LINK
344
- ) ;
324
+ providerId : ProviderId . GOOGLE ,
325
+ operationType : OperationType . LINK
326
+ } ) ;
345
327
idpStubs . _link . returns ( Promise . resolve ( cred ) ) ;
346
328
const promise = linkWithPopup ( user , provider , resolver ) ;
347
329
delay ( ( ) => {
@@ -379,12 +361,11 @@ describe('src/core/strategies/popup', () => {
379
361
} ) ;
380
362
381
363
it ( 'cancels the task if called consecutively' , async ( ) => {
382
- const cred = new UserCredentialImpl (
364
+ const cred = new UserCredentialImpl ( {
383
365
user,
384
- ProviderId . GOOGLE ,
385
- undefined ,
386
- OperationType . LINK
387
- ) ;
366
+ providerId : ProviderId . GOOGLE ,
367
+ operationType : OperationType . LINK
368
+ } ) ;
388
369
idpStubs . _link . returns ( Promise . resolve ( cred ) ) ;
389
370
const firstPromise = linkWithPopup ( user , provider , resolver ) ;
390
371
const secondPromise = linkWithPopup ( user , provider , resolver ) ;
@@ -406,12 +387,11 @@ describe('src/core/strategies/popup', () => {
406
387
} ) ;
407
388
408
389
it ( 'completes the full flow' , async ( ) => {
409
- const cred = new UserCredentialImpl (
390
+ const cred = new UserCredentialImpl ( {
410
391
user,
411
- ProviderId . GOOGLE ,
412
- undefined ,
413
- OperationType . REAUTHENTICATE
414
- ) ;
392
+ providerId : ProviderId . GOOGLE ,
393
+ operationType : OperationType . REAUTHENTICATE
394
+ } ) ;
415
395
idpStubs . _reauth . returns ( Promise . resolve ( cred ) ) ;
416
396
const promise = reauthenticateWithPopup ( user , provider , resolver ) ;
417
397
iframeEvent ( {
@@ -421,12 +401,11 @@ describe('src/core/strategies/popup', () => {
421
401
} ) ;
422
402
423
403
it ( 'ignores events for another event id' , async ( ) => {
424
- const cred = new UserCredentialImpl (
404
+ const cred = new UserCredentialImpl ( {
425
405
user,
426
- ProviderId . GOOGLE ,
427
- undefined ,
428
- OperationType . REAUTHENTICATE
429
- ) ;
406
+ providerId : ProviderId . GOOGLE ,
407
+ operationType : OperationType . REAUTHENTICATE
408
+ } ) ;
430
409
idpStubs . _reauth . returns ( Promise . resolve ( cred ) ) ;
431
410
const promise = reauthenticateWithPopup ( user , provider , resolver ) ;
432
411
iframeEvent ( {
@@ -447,12 +426,11 @@ describe('src/core/strategies/popup', () => {
447
426
} ) ;
448
427
449
428
it ( 'does not call idp tasks if event is error' , async ( ) => {
450
- const cred = new UserCredentialImpl (
429
+ const cred = new UserCredentialImpl ( {
451
430
user,
452
- ProviderId . GOOGLE ,
453
- undefined ,
454
- OperationType . REAUTHENTICATE
455
- ) ;
431
+ providerId : ProviderId . GOOGLE ,
432
+ operationType : OperationType . REAUTHENTICATE
433
+ } ) ;
456
434
idpStubs . _reauth . returns ( Promise . resolve ( cred ) ) ;
457
435
const promise = reauthenticateWithPopup ( user , provider , resolver ) ;
458
436
iframeEvent ( {
@@ -472,12 +450,11 @@ describe('src/core/strategies/popup', () => {
472
450
} ) ;
473
451
474
452
it ( 'does not error if the poll timeout trips' , async ( ) => {
475
- const cred = new UserCredentialImpl (
453
+ const cred = new UserCredentialImpl ( {
476
454
user,
477
- ProviderId . GOOGLE ,
478
- undefined ,
479
- OperationType . REAUTHENTICATE
480
- ) ;
455
+ providerId : ProviderId . GOOGLE ,
456
+ operationType : OperationType . REAUTHENTICATE
457
+ } ) ;
481
458
idpStubs . _reauth . returns ( Promise . resolve ( cred ) ) ;
482
459
const promise = reauthenticateWithPopup ( user , provider , resolver ) ;
483
460
delay ( ( ) => {
@@ -491,12 +468,11 @@ describe('src/core/strategies/popup', () => {
491
468
} ) ;
492
469
493
470
it ( 'does error if the poll timeout and event timeout trip' , async ( ) => {
494
- const cred = new UserCredentialImpl (
471
+ const cred = new UserCredentialImpl ( {
495
472
user,
496
- ProviderId . GOOGLE ,
497
- undefined ,
498
- OperationType . REAUTHENTICATE
499
- ) ;
473
+ providerId : ProviderId . GOOGLE ,
474
+ operationType : OperationType . REAUTHENTICATE
475
+ } ) ;
500
476
idpStubs . _reauth . returns ( Promise . resolve ( cred ) ) ;
501
477
const promise = reauthenticateWithPopup ( user , provider , resolver ) ;
502
478
delay ( ( ) => {
@@ -534,12 +510,11 @@ describe('src/core/strategies/popup', () => {
534
510
} ) ;
535
511
536
512
it ( 'cancels the task if called consecutively' , async ( ) => {
537
- const cred = new UserCredentialImpl (
513
+ const cred = new UserCredentialImpl ( {
538
514
user,
539
- ProviderId . GOOGLE ,
540
- undefined ,
541
- OperationType . REAUTHENTICATE
542
- ) ;
515
+ providerId : ProviderId . GOOGLE ,
516
+ operationType : OperationType . REAUTHENTICATE
517
+ } ) ;
543
518
idpStubs . _reauth . returns ( Promise . resolve ( cred ) ) ;
544
519
const firstPromise = reauthenticateWithPopup ( user , provider , resolver ) ;
545
520
const secondPromise = reauthenticateWithPopup ( user , provider , resolver ) ;
0 commit comments