Skip to content

Commit b12afa7

Browse files
committed
[AUTOMATED]: Prettier Code Styling
1 parent 07ac4b2 commit b12afa7

File tree

2 files changed

+37
-17
lines changed

2 files changed

+37
-17
lines changed

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

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ import { FirebaseError } from '@firebase/util';
1919
import { expect, use } from 'chai';
2020
import * as chaiAsPromised from 'chai-as-promised';
2121
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 '.';
2328
import { mockEndpoint } from '../../test/api/helper';
2429
import { mockAuth } from '../../test/mock_auth';
2530
import * as mockFetch from '../../test/mock_fetch';
@@ -43,12 +48,10 @@ describe('performApiRequest', () => {
4348

4449
it('should set the correct request, method and HTTP Headers', async () => {
4550
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);
5255
expect(response).to.eql(serverResponse);
5356
expect(mock.calls.length).to.eq(1);
5457
expect(mock.calls[0].method).to.eq(HttpMethod.POST);
@@ -140,7 +143,8 @@ describe('performApiRequest', () => {
140143
request,
141144
{
142145
[ServerError.EMAIL_EXISTS]: AuthErrorCode.ARGUMENT_ERROR
143-
});
146+
}
147+
);
144148
await expect(promise).to.be.rejectedWith(
145149
FirebaseError,
146150
'Firebase: Error (auth/argument-error).'
@@ -172,21 +176,29 @@ describe('performApiRequest', () => {
172176
request
173177
);
174178
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+
);
176183
clock.restore();
177184
});
178185

179186
it('should handle network failure', async () => {
180187
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+
);
182191
});
183192
const promise = performApiRequest<typeof request, never>(
184193
mockAuth,
185194
HttpMethod.POST,
186195
Endpoint.SIGN_UP,
187196
request
188197
);
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+
);
190202
});
191203
});
192-
});
204+
});

packages-exp/auth-exp/src/api/index.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export async function performApiRequest<T, V>(
6565
const errorMap = { ...SERVER_ERROR_MAP, ...customErrorMap };
6666
try {
6767
let body = {};
68-
const params: { [key: string]: string; } = {
68+
const params: { [key: string]: string } = {
6969
key: auth.config.apiKey
7070
};
7171
if (request) {
@@ -96,11 +96,17 @@ export async function performApiRequest<T, V>(
9696
referrerPolicy: 'no-referrer',
9797
...body
9898
}
99-
), new Promise((_, reject) =>
99+
),
100+
new Promise((_, reject) =>
100101
setTimeout(() => {
101-
return reject(AUTH_ERROR_FACTORY.create(AuthErrorCode.TIMEOUT, { appName: auth.name }));
102+
return reject(
103+
AUTH_ERROR_FACTORY.create(AuthErrorCode.TIMEOUT, {
104+
appName: auth.name
105+
})
106+
);
102107
}, DEFAULT_API_TIMEOUT_MS)
103-
)]);
108+
)
109+
]);
104110
if (response.ok) {
105111
return response.json();
106112
} else {
@@ -112,7 +118,9 @@ export async function performApiRequest<T, V>(
112118
// TODO probably should handle improperly formatted errors as well
113119
// If you see this, add an entry to SERVER_ERROR_MAP for the corresponding error
114120
console.error(`Unexpected API error: ${json.error.message}`);
115-
throw AUTH_ERROR_FACTORY.create(AuthErrorCode.INTERNAL_ERROR, { appName: auth.name });
121+
throw AUTH_ERROR_FACTORY.create(AuthErrorCode.INTERNAL_ERROR, {
122+
appName: auth.name
123+
});
116124
}
117125
}
118126
} catch (e) {

0 commit comments

Comments
 (0)