Skip to content

Commit da31e42

Browse files
committed
Updated tests
1 parent 00f86c0 commit da31e42

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

packages/data-connect/src/network/fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function dcFetch<T, U>(
4949
if (accessToken) {
5050
headers['X-Firebase-Auth-Token'] = accessToken;
5151
}
52-
if(appId) {
52+
if (appId) {
5353
headers['x-firebase-gmpid'] = appId;
5454
}
5555
if (appCheckToken) {

packages/data-connect/test/unit/fetch.test.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@ describe('fetch', () => {
4040
message
4141
});
4242
await expect(
43-
dcFetch('http://localhost', {}, {} as AbortController, null, null, null, false)
43+
dcFetch(
44+
'http://localhost',
45+
{},
46+
{} as AbortController,
47+
null,
48+
null,
49+
null,
50+
false
51+
)
4452
).to.eventually.be.rejectedWith(message);
4553
});
4654
it('should throw a stringified message when the server responds with an error without a message property in the body', async () => {
@@ -51,7 +59,15 @@ describe('fetch', () => {
5159
};
5260
mockFetch(json);
5361
await expect(
54-
dcFetch('http://localhost', {}, {} as AbortController, null, null, null, false)
62+
dcFetch(
63+
'http://localhost',
64+
{},
65+
{} as AbortController,
66+
null,
67+
null,
68+
null,
69+
false
70+
)
5571
).to.eventually.be.rejectedWith(JSON.stringify(json));
5672
});
5773
});

packages/data-connect/test/unit/gmpid.test.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ const fakeFetchImpl = sinon.stub().returns(
3939
describe('GMPID Tests', () => {
4040
let dc: DataConnect;
4141
let app: FirebaseApp;
42-
let APPID = 'MYAPPID';
42+
const APPID = 'MYAPPID';
4343
beforeEach(() => {
4444
initializeFetch(fakeFetchImpl);
45-
app = initializeApp({ projectId: 'p',appId: APPID }, 'fdsasdf'); // TODO(mtewani): Replace with util function
45+
app = initializeApp({ projectId: 'p', appId: APPID }, 'fdsasdf'); // TODO(mtewani): Replace with util function
4646
dc = getDataConnect(app, { connector: 'c', location: 'l', service: 's' });
4747
});
4848
afterEach(async () => {
@@ -63,7 +63,11 @@ describe('GMPID Tests', () => {
6363
});
6464
it('should send a request with no gmpid if using the app id is not specified', async () => {
6565
const app2 = initializeApp({ projectId: 'p' }, 'def'); // TODO(mtewani): Replace with util function
66-
const dc2 = getDataConnect(app2, { connector: 'c', location: 'l', service: 's' });
66+
const dc2 = getDataConnect(app2, {
67+
connector: 'c',
68+
location: 'l',
69+
service: 's'
70+
});
6771
// @ts-ignore
6872
await executeQuery(queryRef(dc2, '')).catch(() => {});
6973
expect(fakeFetchImpl).to.be.calledWithMatch(
@@ -74,7 +78,7 @@ describe('GMPID Tests', () => {
7478
}
7579
}
7680
);
77-
dc2._delete();
78-
deleteApp(app2);
81+
await dc2._delete();
82+
await deleteApp(app2);
7983
});
8084
});

0 commit comments

Comments
 (0)