@@ -60,10 +60,10 @@ describe('api/_performApiRequest', () => {
60
60
} ) ;
61
61
62
62
context ( 'with regular requests' , ( ) => {
63
+ beforeEach ( mockFetch . setUp ) ;
63
64
afterEach ( mockFetch . tearDown ) ;
64
65
65
66
it ( 'should set the correct request, method and HTTP Headers' , async ( ) => {
66
- mockFetch . setUp ( ) ;
67
67
const mock = mockEndpoint ( Endpoint . SIGN_UP , serverResponse ) ;
68
68
const response = await _performApiRequest <
69
69
typeof request ,
@@ -82,7 +82,6 @@ describe('api/_performApiRequest', () => {
82
82
} ) ;
83
83
84
84
it ( 'should set the device language if available' , async ( ) => {
85
- mockFetch . setUp ( ) ;
86
85
auth . languageCode = 'jp' ;
87
86
const mock = mockEndpoint ( Endpoint . SIGN_UP , serverResponse ) ;
88
87
const response = await _performApiRequest <
@@ -96,7 +95,6 @@ describe('api/_performApiRequest', () => {
96
95
} ) ;
97
96
98
97
it ( 'should include whatever headers the auth impl attaches' , async ( ) => {
99
- mockFetch . setUp ( ) ;
100
98
sinon . stub ( auth , '_getAdditionalHeaders' ) . returns (
101
99
Promise . resolve ( {
102
100
'look-at-me-im-a-header' : 'header-value' ,
@@ -120,7 +118,6 @@ describe('api/_performApiRequest', () => {
120
118
} ) ;
121
119
122
120
it ( 'should set the framework in clientVersion if logged' , async ( ) => {
123
- mockFetch . setUp ( ) ;
124
121
auth . _logFramework ( 'Mythical' ) ;
125
122
const mock = mockEndpoint ( Endpoint . SIGN_UP , serverResponse ) ;
126
123
const response = await _performApiRequest <
@@ -146,7 +143,6 @@ describe('api/_performApiRequest', () => {
146
143
} ) ;
147
144
148
145
it ( 'should translate server errors to auth errors' , async ( ) => {
149
- mockFetch . setUp ( ) ;
150
146
const mock = mockEndpoint (
151
147
Endpoint . SIGN_UP ,
152
148
{
@@ -176,7 +172,6 @@ describe('api/_performApiRequest', () => {
176
172
} ) ;
177
173
178
174
it ( 'should translate server success with errorMessage into auth error' , async ( ) => {
179
- mockFetch . setUp ( ) ;
180
175
const response = {
181
176
errorMessage : ServerError . FEDERATED_USER_ID_ALREADY_LINKED ,
182
177
idToken : 'foo-bar'
@@ -198,7 +193,6 @@ describe('api/_performApiRequest', () => {
198
193
} ) ;
199
194
200
195
it ( 'should translate complex server errors to auth errors' , async ( ) => {
201
- mockFetch . setUp ( ) ;
202
196
const mock = mockEndpoint (
203
197
Endpoint . SIGN_UP ,
204
198
{
@@ -228,7 +222,6 @@ describe('api/_performApiRequest', () => {
228
222
} ) ;
229
223
230
224
it ( 'should pass through server messages if applicable' , async ( ) => {
231
- mockFetch . setUp ( ) ;
232
225
mockEndpoint (
233
226
Endpoint . SIGN_UP ,
234
227
{
@@ -254,7 +247,6 @@ describe('api/_performApiRequest', () => {
254
247
} ) ;
255
248
256
249
it ( 'should handle unknown server errors' , async ( ) => {
257
- mockFetch . setUp ( ) ;
258
250
const mock = mockEndpoint (
259
251
Endpoint . SIGN_UP ,
260
252
{
@@ -284,7 +276,6 @@ describe('api/_performApiRequest', () => {
284
276
} ) ;
285
277
286
278
it ( 'should support custom error handling per endpoint' , async ( ) => {
287
- mockFetch . setUp ( ) ;
288
279
const mock = mockEndpoint (
289
280
Endpoint . SIGN_UP ,
290
281
{
@@ -315,6 +306,10 @@ describe('api/_performApiRequest', () => {
315
306
) ;
316
307
expect ( mock . calls [ 0 ] . request ) . to . eql ( request ) ;
317
308
} ) ;
309
+ } ) ;
310
+
311
+ context ( 'with non-Firebase Errors' , ( ) => {
312
+ afterEach ( mockFetch . tearDown ) ;
318
313
319
314
it ( 'should handle non-FirebaseErrors' , async ( ) => {
320
315
mockFetch . setUpWithOverride ( ( ) => {
0 commit comments