@@ -19,7 +19,12 @@ import { FirebaseError } from '@firebase/util';
19
19
import { expect , use } from 'chai' ;
20
20
import * as chaiAsPromised from 'chai-as-promised' ;
21
21
import { SinonStub , stub , useFakeTimers } from 'sinon' ;
22
- import { DEFAULT_API_TIMEOUT_MS , Endpoint , HttpMethod , performApiRequest } from '.' ;
22
+ import {
23
+ DEFAULT_API_TIMEOUT_MS ,
24
+ Endpoint ,
25
+ HttpMethod ,
26
+ performApiRequest
27
+ } from '.' ;
23
28
import { mockEndpoint } from '../../test/api/helper' ;
24
29
import { mockAuth } from '../../test/mock_auth' ;
25
30
import * as mockFetch from '../../test/mock_fetch' ;
@@ -43,12 +48,10 @@ describe('performApiRequest', () => {
43
48
44
49
it ( 'should set the correct request, method and HTTP Headers' , async ( ) => {
45
50
const mock = mockEndpoint ( Endpoint . SIGN_UP , serverResponse ) ;
46
- const response = await performApiRequest < typeof request , typeof serverResponse > (
47
- mockAuth ,
48
- HttpMethod . POST ,
49
- Endpoint . SIGN_UP ,
50
- request
51
- ) ;
51
+ const response = await performApiRequest <
52
+ typeof request ,
53
+ typeof serverResponse
54
+ > ( mockAuth , HttpMethod . POST , Endpoint . SIGN_UP , request ) ;
52
55
expect ( response ) . to . eql ( serverResponse ) ;
53
56
expect ( mock . calls . length ) . to . eq ( 1 ) ;
54
57
expect ( mock . calls [ 0 ] . method ) . to . eq ( HttpMethod . POST ) ;
@@ -140,7 +143,8 @@ describe('performApiRequest', () => {
140
143
request ,
141
144
{
142
145
[ ServerError . EMAIL_EXISTS ] : AuthErrorCode . ARGUMENT_ERROR
143
- } ) ;
146
+ }
147
+ ) ;
144
148
await expect ( promise ) . to . be . rejectedWith (
145
149
FirebaseError ,
146
150
'Firebase: Error (auth/argument-error).'
@@ -172,21 +176,29 @@ describe('performApiRequest', () => {
172
176
request
173
177
) ;
174
178
clock . tick ( DEFAULT_API_TIMEOUT_MS + 1 ) ;
175
- await expect ( promise ) . to . be . rejectedWith ( FirebaseError , 'Firebase: The operation has timed out. (auth/timeout).' ) ;
179
+ await expect ( promise ) . to . be . rejectedWith (
180
+ FirebaseError ,
181
+ 'Firebase: The operation has timed out. (auth/timeout).'
182
+ ) ;
176
183
clock . restore ( ) ;
177
184
} ) ;
178
185
179
186
it ( 'should handle network failure' , async ( ) => {
180
187
fetchStub . callsFake ( ( ) => {
181
- return new Promise < never > ( ( _ , reject ) => reject ( new Error ( 'network error' ) ) ) ;
188
+ return new Promise < never > ( ( _ , reject ) =>
189
+ reject ( new Error ( 'network error' ) )
190
+ ) ;
182
191
} ) ;
183
192
const promise = performApiRequest < typeof request , never > (
184
193
mockAuth ,
185
194
HttpMethod . POST ,
186
195
Endpoint . SIGN_UP ,
187
196
request
188
197
) ;
189
- await expect ( promise ) . to . be . rejectedWith ( FirebaseError , 'Firebase: A network AuthError (such as timeout]: interrupted connection or unreachable host) has occurred. (auth/network-request-failed).' ) ;
198
+ await expect ( promise ) . to . be . rejectedWith (
199
+ FirebaseError ,
200
+ 'Firebase: A network AuthError (such as timeout]: interrupted connection or unreachable host) has occurred. (auth/network-request-failed).'
201
+ ) ;
190
202
} ) ;
191
203
} ) ;
192
- } ) ;
204
+ } ) ;
0 commit comments