@@ -28,12 +28,18 @@ import {
28
28
EventManager ,
29
29
PopupRedirectResolver
30
30
} from '../../model/popup_redirect' ;
31
- import { CordovaAuthEventManager , cordovaPopupRedirectResolver } from './popup_redirect' ;
31
+ import {
32
+ CordovaAuthEventManager ,
33
+ cordovaPopupRedirectResolver
34
+ } from './popup_redirect' ;
32
35
import { GoogleAuthProvider } from '../../core/providers/google' ;
33
36
import * as utils from './utils' ;
34
37
import * as events from './events' ;
35
38
import { FirebaseError } from '@firebase/util' ;
36
- import { stubSingleTimeout , TimerTripFn } from '../../../test/helpers/timeout_stub' ;
39
+ import {
40
+ stubSingleTimeout ,
41
+ TimerTripFn
42
+ } from '../../../test/helpers/timeout_stub' ;
37
43
38
44
use ( chaiAsPromised ) ;
39
45
use ( sinonChai ) ;
@@ -91,19 +97,21 @@ describe('platform_cordova/popup_redirect/popup_redirect', () => {
91
97
const NO_EVENT_TIMER_ID = 10001 ;
92
98
const PACKAGE_NAME = 'my.package' ;
93
99
const NOT_PACKAGE_NAME = 'not.my.package' ;
94
- let universalLinksCb : ( ( eventData : Record < string , string > | null ) => unknown ) | null ;
100
+ let universalLinksCb :
101
+ | ( ( eventData : Record < string , string > | null ) => unknown )
102
+ | null ;
95
103
let tripNoEventTimer : TimerTripFn ;
96
104
97
105
beforeEach ( ( ) => {
98
106
tripNoEventTimer = stubSingleTimeout ( NO_EVENT_TIMER_ID ) ;
99
107
window . universalLinks = {
100
- subscribe ( _unused , cb ) {
108
+ subscribe ( _unused , cb ) {
101
109
universalLinksCb = cb ;
102
- } ,
110
+ }
103
111
} ;
104
112
window . BuildInfo = {
105
113
packageName : PACKAGE_NAME ,
106
- displayName : '' ,
114
+ displayName : ''
107
115
} ;
108
116
sinon . stub ( window , 'clearTimeout' ) ;
109
117
} ) ;
@@ -122,23 +130,25 @@ describe('platform_cordova/popup_redirect/popup_redirect', () => {
122
130
it ( 'clears local storage and dispatches no-event event' , async ( ) => {
123
131
const promise = event ( await resolver . _initialize ( auth ) ) ;
124
132
tripNoEventTimer ( ) ;
125
- const { error, ...rest } = await promise ;
133
+ const { error, ...rest } = await promise ;
126
134
127
- expect ( error ) . to . be . instanceOf ( FirebaseError ) . with . property ( 'code' , 'auth/no-auth-event' ) ;
135
+ expect ( error )
136
+ . to . be . instanceOf ( FirebaseError )
137
+ . with . property ( 'code' , 'auth/no-auth-event' ) ;
128
138
expect ( rest ) . to . eql ( {
129
139
type : AuthEventType . UNKNOWN ,
130
140
eventId : null ,
131
141
sessionId : null ,
132
142
urlResponse : null ,
133
143
postBody : null ,
134
- tenantId : null ,
144
+ tenantId : null
135
145
} ) ;
136
146
expect ( events . _getAndRemoveEvent ) . to . have . been . called ;
137
147
} ) ;
138
148
} ) ;
139
149
140
150
context ( 'when an event is present' , ( ) => {
141
- it ( 'clears the no event timeout' , async ( ) => {
151
+ it ( 'clears the no event timeout' , async ( ) => {
142
152
await resolver . _initialize ( auth ) ;
143
153
await universalLinksCb ! ( { } ) ;
144
154
expect ( window . clearTimeout ) . to . have . been . calledWith ( NO_EVENT_TIMER_ID ) ;
@@ -147,54 +157,62 @@ describe('platform_cordova/popup_redirect/popup_redirect', () => {
147
157
it ( 'signals no event if no url in event data' , async ( ) => {
148
158
const promise = event ( await resolver . _initialize ( auth ) ) ;
149
159
await universalLinksCb ! ( { } ) ;
150
- const { error, ...rest } = await promise ;
160
+ const { error, ...rest } = await promise ;
151
161
152
- expect ( error ) . to . be . instanceOf ( FirebaseError ) . with . property ( 'code' , 'auth/no-auth-event' ) ;
162
+ expect ( error )
163
+ . to . be . instanceOf ( FirebaseError )
164
+ . with . property ( 'code' , 'auth/no-auth-event' ) ;
153
165
expect ( rest ) . to . eql ( {
154
166
type : AuthEventType . UNKNOWN ,
155
167
eventId : null ,
156
168
sessionId : null ,
157
169
urlResponse : null ,
158
170
postBody : null ,
159
- tenantId : null ,
171
+ tenantId : null
160
172
} ) ;
161
173
} ) ;
162
174
163
175
it ( 'signals no event if partial parse turns up null' , async ( ) => {
164
176
const promise = event ( await resolver . _initialize ( auth ) ) ;
165
177
eventsStubs . _eventFromPartialAndUrl . returns ( null ) ;
166
- eventsStubs . _getAndRemoveEvent . returns ( Promise . resolve ( {
167
- type : AuthEventType . REAUTH_VIA_REDIRECT ,
168
- } as AuthEvent ) ) ;
169
- await universalLinksCb ! ( { url : 'foo-bar' } ) ;
170
- const { error, ...rest } = await promise ;
178
+ eventsStubs . _getAndRemoveEvent . returns (
179
+ Promise . resolve ( {
180
+ type : AuthEventType . REAUTH_VIA_REDIRECT
181
+ } as AuthEvent )
182
+ ) ;
183
+ await universalLinksCb ! ( { url : 'foo-bar' } ) ;
184
+ const { error, ...rest } = await promise ;
171
185
172
- expect ( error ) . to . be . instanceOf ( FirebaseError ) . with . property ( 'code' , 'auth/no-auth-event' ) ;
186
+ expect ( error )
187
+ . to . be . instanceOf ( FirebaseError )
188
+ . with . property ( 'code' , 'auth/no-auth-event' ) ;
173
189
expect ( rest ) . to . eql ( {
174
190
type : AuthEventType . UNKNOWN ,
175
191
eventId : null ,
176
192
sessionId : null ,
177
193
urlResponse : null ,
178
194
postBody : null ,
179
- tenantId : null ,
195
+ tenantId : null
180
196
} ) ;
181
197
} ) ;
182
198
183
199
it ( 'signals the final event if partial expansion success' , async ( ) => {
184
200
const finalEvent = {
185
201
type : AuthEventType . REAUTH_VIA_REDIRECT ,
186
- postBody : 'foo' ,
202
+ postBody : 'foo'
187
203
} ;
188
- eventsStubs . _getAndRemoveEvent . returns ( Promise . resolve ( {
189
- type : AuthEventType . REAUTH_VIA_REDIRECT ,
190
- } as AuthEvent ) ) ;
204
+ eventsStubs . _getAndRemoveEvent . returns (
205
+ Promise . resolve ( {
206
+ type : AuthEventType . REAUTH_VIA_REDIRECT
207
+ } as AuthEvent )
208
+ ) ;
191
209
192
210
const promise = event ( await resolver . _initialize ( auth ) ) ;
193
211
eventsStubs . _eventFromPartialAndUrl . returns ( finalEvent as AuthEvent ) ;
194
- await universalLinksCb ! ( { url : 'foo-bar' } ) ;
212
+ await universalLinksCb ! ( { url : 'foo-bar' } ) ;
195
213
expect ( await promise ) . to . eq ( finalEvent ) ;
196
214
expect ( events . _eventFromPartialAndUrl ) . to . have . been . calledWith (
197
- { type : AuthEventType . REAUTH_VIA_REDIRECT } ,
215
+ { type : AuthEventType . REAUTH_VIA_REDIRECT } ,
198
216
'foo-bar'
199
217
) ;
200
218
} ) ;
@@ -218,18 +236,20 @@ describe('platform_cordova/popup_redirect/popup_redirect', () => {
218
236
it ( 'signals the final event if partial expansion success' , async ( ) => {
219
237
const finalEvent = {
220
238
type : AuthEventType . REAUTH_VIA_REDIRECT ,
221
- postBody : 'foo' ,
239
+ postBody : 'foo'
222
240
} ;
223
- eventsStubs . _getAndRemoveEvent . returns ( Promise . resolve ( {
224
- type : AuthEventType . REAUTH_VIA_REDIRECT ,
225
- } as AuthEvent ) ) ;
241
+ eventsStubs . _getAndRemoveEvent . returns (
242
+ Promise . resolve ( {
243
+ type : AuthEventType . REAUTH_VIA_REDIRECT
244
+ } as AuthEvent )
245
+ ) ;
226
246
227
247
const promise = event ( await resolver . _initialize ( auth ) ) ;
228
248
eventsStubs . _eventFromPartialAndUrl . returns ( finalEvent as AuthEvent ) ;
229
249
handleOpenUrl ( `${ PACKAGE_NAME } ://foo` ) ;
230
250
expect ( await promise ) . to . eq ( finalEvent ) ;
231
251
expect ( events . _eventFromPartialAndUrl ) . to . have . been . calledWith (
232
- { type : AuthEventType . REAUTH_VIA_REDIRECT } ,
252
+ { type : AuthEventType . REAUTH_VIA_REDIRECT } ,
233
253
`${ PACKAGE_NAME } ://foo`
234
254
) ;
235
255
} ) ;
@@ -240,7 +260,9 @@ describe('platform_cordova/popup_redirect/popup_redirect', () => {
240
260
241
261
await resolver . _initialize ( auth ) ;
242
262
handleOpenUrl ( `${ PACKAGE_NAME } ://foo` ) ;
243
- expect ( oldHandleOpenUrl ) . to . have . been . calledWith ( `${ PACKAGE_NAME } ://foo` ) ;
263
+ expect ( oldHandleOpenUrl ) . to . have . been . calledWith (
264
+ `${ PACKAGE_NAME } ://foo`
265
+ ) ;
244
266
} ) ;
245
267
} ) ;
246
268
} ) ;
0 commit comments