Skip to content

Commit 0c5b27e

Browse files
committed
Modify test case
1 parent 3d8f497 commit 0c5b27e

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ describe('api/_performApiRequest', () => {
6060
});
6161

6262
context('with regular requests', () => {
63+
beforeEach(mockFetch.setUp);
6364
afterEach(mockFetch.tearDown);
6465

6566
it('should set the correct request, method and HTTP Headers', async () => {
66-
mockFetch.setUp();
6767
const mock = mockEndpoint(Endpoint.SIGN_UP, serverResponse);
6868
const response = await _performApiRequest<
6969
typeof request,
@@ -82,7 +82,6 @@ describe('api/_performApiRequest', () => {
8282
});
8383

8484
it('should set the device language if available', async () => {
85-
mockFetch.setUp();
8685
auth.languageCode = 'jp';
8786
const mock = mockEndpoint(Endpoint.SIGN_UP, serverResponse);
8887
const response = await _performApiRequest<
@@ -96,7 +95,6 @@ describe('api/_performApiRequest', () => {
9695
});
9796

9897
it('should include whatever headers the auth impl attaches', async () => {
99-
mockFetch.setUp();
10098
sinon.stub(auth, '_getAdditionalHeaders').returns(
10199
Promise.resolve({
102100
'look-at-me-im-a-header': 'header-value',
@@ -120,7 +118,6 @@ describe('api/_performApiRequest', () => {
120118
});
121119

122120
it('should set the framework in clientVersion if logged', async () => {
123-
mockFetch.setUp();
124121
auth._logFramework('Mythical');
125122
const mock = mockEndpoint(Endpoint.SIGN_UP, serverResponse);
126123
const response = await _performApiRequest<
@@ -146,7 +143,6 @@ describe('api/_performApiRequest', () => {
146143
});
147144

148145
it('should translate server errors to auth errors', async () => {
149-
mockFetch.setUp();
150146
const mock = mockEndpoint(
151147
Endpoint.SIGN_UP,
152148
{
@@ -176,7 +172,6 @@ describe('api/_performApiRequest', () => {
176172
});
177173

178174
it('should translate server success with errorMessage into auth error', async () => {
179-
mockFetch.setUp();
180175
const response = {
181176
errorMessage: ServerError.FEDERATED_USER_ID_ALREADY_LINKED,
182177
idToken: 'foo-bar'
@@ -198,7 +193,6 @@ describe('api/_performApiRequest', () => {
198193
});
199194

200195
it('should translate complex server errors to auth errors', async () => {
201-
mockFetch.setUp();
202196
const mock = mockEndpoint(
203197
Endpoint.SIGN_UP,
204198
{
@@ -228,7 +222,6 @@ describe('api/_performApiRequest', () => {
228222
});
229223

230224
it('should pass through server messages if applicable', async () => {
231-
mockFetch.setUp();
232225
mockEndpoint(
233226
Endpoint.SIGN_UP,
234227
{
@@ -254,7 +247,6 @@ describe('api/_performApiRequest', () => {
254247
});
255248

256249
it('should handle unknown server errors', async () => {
257-
mockFetch.setUp();
258250
const mock = mockEndpoint(
259251
Endpoint.SIGN_UP,
260252
{
@@ -284,7 +276,6 @@ describe('api/_performApiRequest', () => {
284276
});
285277

286278
it('should support custom error handling per endpoint', async () => {
287-
mockFetch.setUp();
288279
const mock = mockEndpoint(
289280
Endpoint.SIGN_UP,
290281
{
@@ -315,6 +306,10 @@ describe('api/_performApiRequest', () => {
315306
);
316307
expect(mock.calls[0].request).to.eql(request);
317308
});
309+
});
310+
311+
context('with non-Firebase Errors', () => {
312+
afterEach(mockFetch.tearDown);
318313

319314
it('should handle non-FirebaseErrors', async () => {
320315
mockFetch.setUpWithOverride(() => {

0 commit comments

Comments
 (0)