Skip to content

Commit b486cd7

Browse files
committed
WIP
1 parent f5930ab commit b486cd7

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import {
4141
import { ServerError } from './errors';
4242
import { SDK_VERSION } from '@firebase/app';
4343
import { _getBrowserName } from '../core/util/browser';
44+
import { FetchProvider } from '../../internal';
4445

4546
use(sinonChai);
4647
use(chaiAsPromised);
@@ -56,30 +57,31 @@ describe('api/_performApiRequest', () => {
5657

5758
let auth: TestAuth;
5859

60+
let fetchSpy: sinon.SinonSpy;
61+
5962
beforeEach(async () => {
6063
auth = await testAuth();
6164
});
6265

63-
context('with regular requests', () => {
64-
beforeEach(mockFetch.setUp);
66+
afterEach(() => {
67+
sinon.restore();
68+
})
69+
70+
context.only('with regular requests', () => {
71+
72+
beforeEach(() => {
73+
mockFetch.setUp();
74+
fetchSpy = sinon.spy(FetchProvider.fetch());
75+
})
6576
afterEach(mockFetch.tearDown);
6677

67-
it('should set the correct request, method and HTTP Headers', async () => {
78+
it.only('should set the correct request, method and HTTP Headers', async () => {
6879
const mock = mockEndpoint(Endpoint.SIGN_UP, serverResponse);
6980
const response = await _performApiRequest<
7081
typeof request,
7182
typeof serverResponse
7283
>(auth, HttpMethod.POST, Endpoint.SIGN_UP, request);
73-
expect(response).to.eql(serverResponse);
74-
expect(mock.calls.length).to.eq(1);
75-
expect(mock.calls[0].method).to.eq(HttpMethod.POST);
76-
expect(mock.calls[0].request).to.eql(request);
77-
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
78-
'application/json'
79-
);
80-
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
81-
'testSDK/0.0.0'
82-
);
84+
expect(fetchSpy).to.have.been.called;
8385
});
8486

8587
it('should set the device language if available', async () => {

packages/auth/src/core/util/fetch_provider.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export class FetchProvider {
3737
}
3838

3939
static fetch(): typeof fetch {
40-
console.log('fetch!');
4140
if (this.fetchImpl) {
4241
return this.fetchImpl;
4342
}

0 commit comments

Comments
 (0)