Skip to content

Commit f45f6b2

Browse files
committed
Fixed tests
1 parent 0c46097 commit f45f6b2

File tree

5 files changed

+9
-18
lines changed

5 files changed

+9
-18
lines changed

packages/data-connect/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"dev": "rollup -c -w",
3636
"test": "run-p --npm-path npm test:emulator",
3737
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:emulator",
38-
"test:all": "npm run test:node",
38+
"test:all": "npm run test:unit",
3939
"test:browser": "karma start --single-run",
4040
"test:node": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js",
4141
"test:unit": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/unit/**/*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js",
@@ -57,7 +57,7 @@
5757
"tslib": "^2.1.0"
5858
},
5959
"devDependencies": {
60-
"@firebase/app": "0.10.7",
60+
"@firebase/app": "0.10.10",
6161
"rollup": "2.79.1",
6262
"rollup-plugin-typescript2": "0.31.2",
6363
"typescript": "4.7.4"

packages/data-connect/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
*/
2323
import { DataConnect } from './api/DataConnect';
2424
import { registerDataConnect } from './register';
25-
// import CryptoJS from 'crypto-js/hmac-sha512';
2625

2726
export * from './api';
2827
export * from './api.browser';

packages/data-connect/src/network/transport/rest.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export class RESTTransport implements DataConnectTransport {
7373
this._accessToken = token;
7474
});
7575
this.appCheckProvider?.addTokenChangeListener(result => {
76-
console.log('getting token');
7776
const { token } = result;
7877
logDebug(`New App Check Token Available: ${token}`);
7978
this._appCheckToken = token;
@@ -108,7 +107,7 @@ export class RESTTransport implements DataConnectTransport {
108107
resolve(this._accessToken)
109108
);
110109
if (this.appCheckProvider) {
111-
this._appCheckToken = (await this.appCheckProvider.getToken()).token;
110+
this._appCheckToken = (await this.appCheckProvider.getToken())?.token;
112111
}
113112
if (this.authProvider) {
114113
starterPromise = this.authProvider

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import sinonChai from 'sinon-chai';
2222
import { DataConnect, executeQuery, getDataConnect, queryRef } from '../../src';
2323
import { SDK_VERSION } from '../../src/core/version';
2424
import { initializeFetch } from '../../src/network/fetch';
25+
import { deleteApp, initializeApp, FirebaseApp } from '@firebase/app';
2526

2627
use(sinonChai);
2728
const json = {
@@ -38,12 +39,15 @@ const fakeFetchImpl = sinon.stub().returns(
3839

3940
describe('User Agent Tests', () => {
4041
let dc: DataConnect;
42+
let app: FirebaseApp;
4143
beforeEach(() => {
4244
initializeFetch(fakeFetchImpl);
43-
dc = getDataConnect({ connector: 'c', location: 'l', service: 's' });
45+
app = initializeApp({projectId: 'p'}, 'abc'); // TODO(mtewani): Replace with util function
46+
dc = getDataConnect(app, { connector: 'c', location: 'l', service: 's' });
4447
});
4548
afterEach(async () => {
4649
await dc._delete();
50+
await deleteApp(app);
4751
});
4852
it('should send a request with the corresponding user agent if using the generated SDK', async () => {
4953
dc._useGeneratedSdk();
@@ -58,7 +62,7 @@ describe('User Agent Tests', () => {
5862
}
5963
);
6064
});
61-
it('should send a request with the corresponding user agent if using the generated SDK', async () => {
65+
it('should send a request with the corresponding user agent if not using the generated SDK', async () => {
6266
// @ts-ignore
6367
await executeQuery(queryRef(dc, '')).catch(() => {});
6468
expect(fakeFetchImpl).to.be.calledWithMatch(

yarn.lock

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,17 +1639,6 @@
16391639
resolved "https://registry.npmjs.org/@eslint/js/-/js-8.56.0.tgz#ef20350fec605a7f7035a01764731b2de0f3782b"
16401640
integrity sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==
16411641

1642-
"@firebase/[email protected]":
1643-
version "0.10.7"
1644-
resolved "https://registry.npmjs.org/@firebase/app/-/app-0.10.7.tgz#31cba1486c21b5a0cadc0036bfc0cec68ff53c8e"
1645-
integrity sha512-7OCd53B+wnk/onbMLn/vM10pDjw97zzWUD8m3swtLYKJIrL+gDZ7HZ4xcbBLw7OB8ikzu8k1ORNjRe2itgAy4g==
1646-
dependencies:
1647-
"@firebase/component" "0.6.8"
1648-
"@firebase/logger" "0.4.2"
1649-
"@firebase/util" "1.9.7"
1650-
idb "7.1.1"
1651-
tslib "^2.1.0"
1652-
16531642
"@gar/promisify@^1.0.1":
16541643
version "1.1.2"
16551644
resolved "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.2.tgz"

0 commit comments

Comments
 (0)