Skip to content

Commit c2d864b

Browse files
committed
Got tests to work
1 parent 4de00dd commit c2d864b

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +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';
44+
import { connectAuthEmulator, FetchProvider } from '../../internal';
4545

4646
use(sinonChai);
4747
use(chaiAsPromised);
@@ -65,23 +65,30 @@ describe('api/_performApiRequest', () => {
6565

6666
afterEach(() => {
6767
sinon.restore();
68-
})
68+
});
6969

7070
context.only('with regular requests', () => {
71-
7271
beforeEach(() => {
7372
mockFetch.setUp();
7473
fetchSpy = sinon.spy(FetchProvider.fetch());
75-
})
74+
});
7675
afterEach(mockFetch.tearDown);
7776

7877
it.only('should set the correct request, method and HTTP Headers', async () => {
7978
const mock = mockEndpoint(Endpoint.SIGN_UP, serverResponse);
79+
auth.emulatorConfig = {
80+
host: 'https://something.cloudworkstations.dev',
81+
protocol: '',
82+
port: 8,
83+
options: {
84+
disableWarnings: false
85+
}
86+
};
8087
const response = await _performApiRequest<
8188
typeof request,
8289
typeof serverResponse
8390
>(auth, HttpMethod.POST, Endpoint.SIGN_UP, request);
84-
expect(fetchSpy).to.have.been.called;
91+
expect(mock.calls[0].fullRequest?.credentials).to.eq('include');
8592
});
8693

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

packages/auth/src/core/auth/emulator.test.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ describe.only('core/auth/emulator', () => {
4343

4444
beforeEach(async () => {
4545
auth = await testAuth();
46-
spy = sinon.spy(FetchProvider.fetch());
4746
user = testUser(_castAuth(auth), 'uid', 'email', true);
4847
fetch.setUp();
4948
normalEndpoint = mockEndpoint(Endpoint.DELETE_ACCOUNT, {});
@@ -96,16 +95,6 @@ describe.only('core/auth/emulator', () => {
9695
'auth/emulator-config-failed'
9796
);
9897
});
99-
it.only('sends the proper value', async () => {
100-
expect(() => connectAuthEmulator(auth, 'http://127.0.0.1:2020')).to.not
101-
.throw;
102-
await user.delete();
103-
expect(spy).to.have.been.called;
104-
expect(() => connectAuthEmulator(auth, 'http://127.0.0.1:2021')).to.throw(
105-
FirebaseError,
106-
'auth/emulator-config-failed'
107-
);
108-
});
10998

11099
it('subsequent calls update the endpoint appropriately', async () => {
111100
connectAuthEmulator(auth, 'http://127.0.0.1:2021');
@@ -124,7 +113,7 @@ describe.only('core/auth/emulator', () => {
124113
});
125114
});
126115

127-
it('subsequent calls update the endpoint appropriately', async () => {
116+
it('subsequent calls update the endpoint appropriately', async () => {
128117
connectAuthEmulator(auth, 'http://127.0.0.1:2021');
129118
expect(auth.emulatorConfig).to.eql({
130119
protocol: 'http',

packages/auth/test/helpers/mock_fetch.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface Call {
2222
request?: object | string;
2323
method?: string;
2424
headers: Headers;
25+
fullRequest?: RequestInit;
2526
}
2627

2728
export interface Route {
@@ -59,7 +60,8 @@ const fakeFetch: typeof fetch = (
5960
calls.push({
6061
request: requestBody,
6162
method: request?.method,
62-
headers
63+
headers,
64+
fullRequest: request
6365
});
6466

6567
return Promise.resolve(

0 commit comments

Comments
 (0)