Skip to content

Commit 1b4f30a

Browse files
committed
Change _fail to use AuthErrorCode.NETWORK_REQUEST_FAILED
1 parent 0c5b27e commit 1b4f30a

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

packages/auth/src/api/index.test.ts

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -308,26 +308,6 @@ describe('api/_performApiRequest', () => {
308308
});
309309
});
310310

311-
context('with non-Firebase Errors', () => {
312-
afterEach(mockFetch.tearDown);
313-
314-
it('should handle non-FirebaseErrors', async () => {
315-
mockFetch.setUpWithOverride(() => {
316-
return new Promise<never>((_, reject) => reject(new Error('error')));
317-
});
318-
const promise = _performApiRequest<typeof request, never>(
319-
auth,
320-
HttpMethod.POST,
321-
Endpoint.SIGN_UP,
322-
request
323-
);
324-
await expect(promise).to.be.rejectedWith(
325-
FirebaseError,
326-
'auth/internal-error'
327-
);
328-
});
329-
});
330-
331311
context('with network issues', () => {
332312
afterEach(mockFetch.tearDown);
333313

@@ -365,6 +345,24 @@ describe('api/_performApiRequest', () => {
365345
expect(clock.clearTimeout).to.have.been.called;
366346
clock.restore();
367347
});
348+
349+
it('should handle network failure', async () => {
350+
mockFetch.setUpWithOverride(() => {
351+
return new Promise<never>((_, reject) =>
352+
reject(new Error('network error'))
353+
);
354+
});
355+
const promise = _performApiRequest<typeof request, never>(
356+
auth,
357+
HttpMethod.POST,
358+
Endpoint.SIGN_UP,
359+
request
360+
);
361+
await expect(promise).to.be.rejectedWith(
362+
FirebaseError,
363+
'auth/network-request-failed'
364+
);
365+
});
368366
});
369367

370368
context('edgcase error mapping', () => {
@@ -524,4 +522,4 @@ describe('api/_performApiRequest', () => {
524522
.and.not.have.property('tenantId');
525523
});
526524
});
527-
});
525+
});

packages/auth/src/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export async function _performFetchWithErrorHandling<V>(
181181
if (e instanceof FirebaseError) {
182182
throw e;
183183
}
184-
_fail(auth, AuthErrorCode.INTERNAL_ERROR, { 'message': String(e) });
184+
_fail(auth, AuthErrorCode.NETWORK_REQUEST_FAILED, { 'message': String(e) });
185185
}
186186
}
187187

0 commit comments

Comments
 (0)