Skip to content

Commit d98d12d

Browse files
committed
Fix tests
1 parent 8767c12 commit d98d12d

31 files changed

+73
-44
lines changed

packages/app/test/firebaseApp.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import './setup';
19+
1820
import { FirebaseApp, FirebaseNamespace } from '@firebase/app-types';
1921
import {
2022
_FirebaseApp,

packages/app/test/setup.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// https://github.com/TypeStrong/ts-node#help-my-types-are-missing
2+
/// <reference types="../declarations" />
3+
4+
import { root } from '@firebase/util';
5+
6+
root.__JSCORE_VERSION__ = '__JSCORE_VERSION__';

packages/installations/src/api/create-installation.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../testing/setup';
19+
1820
import { expect } from 'chai';
1921
import { SinonStub, stub } from 'sinon';
2022
import { CreateInstallationResponse } from '../interfaces/api-response';
@@ -25,7 +27,6 @@ import {
2527
} from '../interfaces/installation-entry';
2628
import { compareHeaders } from '../testing/compare-headers';
2729
import { getFakeAppConfig } from '../testing/get-fake-app';
28-
import '../testing/setup';
2930
import {
3031
INSTALLATIONS_API_URL,
3132
INTERNAL_AUTH_VERSION,

packages/installations/src/api/delete-installation.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../testing/setup';
19+
1820
import { expect } from 'chai';
1921
import { SinonStub, stub } from 'sinon';
2022
import { AppConfig } from '../interfaces/app-config';
@@ -24,7 +26,6 @@ import {
2426
} from '../interfaces/installation-entry';
2527
import { compareHeaders } from '../testing/compare-headers';
2628
import { getFakeAppConfig } from '../testing/get-fake-app';
27-
import '../testing/setup';
2829
import {
2930
INSTALLATIONS_API_URL,
3031
INTERNAL_AUTH_VERSION

packages/installations/src/api/generate-auth-token.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../testing/setup';
19+
1820
import { expect } from 'chai';
1921
import { SinonStub, stub } from 'sinon';
2022
import { GenerateAuthTokenResponse } from '../interfaces/api-response';
@@ -26,7 +28,6 @@ import {
2628
} from '../interfaces/installation-entry';
2729
import { compareHeaders } from '../testing/compare-headers';
2830
import { getFakeAppConfig } from '../testing/get-fake-app';
29-
import '../testing/setup';
3031
import {
3132
INSTALLATIONS_API_URL,
3233
INTERNAL_AUTH_VERSION,

packages/installations/src/functions/delete-installation.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../testing/setup';
19+
1820
import { FirebaseApp } from '@firebase/app-types';
1921
import { expect } from 'chai';
2022
import { SinonStub, stub } from 'sinon';
@@ -29,7 +31,6 @@ import {
2931
UnregisteredInstallationEntry
3032
} from '../interfaces/installation-entry';
3133
import { getFakeApp } from '../testing/get-fake-app';
32-
import '../testing/setup';
3334
import { ErrorCode } from '../util/errors';
3435
import { sleep } from '../util/sleep';
3536
import { deleteInstallation } from './delete-installation';

packages/installations/src/functions/get-id.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../testing/setup';
19+
1820
import { expect } from 'chai';
1921
import { SinonStub, stub } from 'sinon';
2022
import * as getInstallationEntryModule from '../helpers/get-installation-entry';
2123
import { AppConfig } from '../interfaces/app-config';
2224
import { RequestStatus } from '../interfaces/installation-entry';
2325
import { getFakeApp } from '../testing/get-fake-app';
24-
import '../testing/setup';
2526
import { getId } from './get-id';
2627

2728
const FID = 'children-of-the-damned';

packages/installations/src/functions/get-token.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../testing/setup';
19+
1820
import { FirebaseApp } from '@firebase/app-types';
1921
import { expect } from 'chai';
2022
import { SinonFakeTimers, SinonStub, stub, useFakeTimers } from 'sinon';
@@ -31,7 +33,6 @@ import {
3133
UnregisteredInstallationEntry
3234
} from '../interfaces/installation-entry';
3335
import { getFakeApp } from '../testing/get-fake-app';
34-
import '../testing/setup';
3536
import { TOKEN_EXPIRATION_BUFFER } from '../util/constants';
3637
import { ERROR_FACTORY, ErrorCode } from '../util/errors';
3738
import { sleep } from '../util/sleep';

packages/installations/src/helpers/buffer-to-base64-url-safe.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { expect } from 'chai';
1918
import '../testing/setup';
19+
20+
import { expect } from 'chai';
2021
import { bufferToBase64UrlSafe } from './buffer-to-base64-url-safe';
2122

2223
const TYPED_ARRAY_REPRESENTATION = new TextEncoder().encode('hello world');

packages/installations/src/helpers/extract-app-config.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../testing/setup';
19+
1820
import { FirebaseError } from '@firebase/util';
1921
import { expect } from 'chai';
2022
import { AppConfig } from '../interfaces/app-config';
2123
import { getFakeApp } from '../testing/get-fake-app';
22-
import '../testing/setup';
2324
import { extractAppConfig } from './extract-app-config';
2425

2526
describe('extractAppConfig', () => {

packages/installations/src/helpers/generate-fid.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../testing/setup';
19+
1820
import { expect } from 'chai';
1921
import { stub } from 'sinon';
20-
import '../testing/setup';
2122
import { generateFid } from './generate-fid';
2223

2324
/** A few random values to generate a FID from. */

packages/installations/src/helpers/get-installation-entry.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../testing/setup';
19+
1820
import { AssertionError, expect } from 'chai';
1921
import { SinonFakeTimers, SinonStub, stub, useFakeTimers } from 'sinon';
2022
import * as createInstallationModule from '../api/create-installation';
@@ -27,7 +29,6 @@ import {
2729
UnregisteredInstallationEntry
2830
} from '../interfaces/installation-entry';
2931
import { getFakeAppConfig } from '../testing/get-fake-app';
30-
import '../testing/setup';
3132
import { ERROR_FACTORY, ErrorCode } from '../util/errors';
3233
import { sleep } from '../util/sleep';
3334
import * as fidGenerator from './generate-fid';

packages/installations/src/helpers/idb-manager.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../testing/setup';
19+
1820
import { expect } from 'chai';
1921
import { AppConfig } from '../interfaces/app-config';
2022
import { getFakeAppConfig } from '../testing/get-fake-app';
21-
import '../testing/setup';
2223
import { clear, get, remove, set, update } from './idb-manager';
2324

2425
describe('idb manager', () => {

packages/installations/src/testing/compare-headers.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { AssertionError, expect } from 'chai';
1918
import '../testing/setup';
19+
20+
import { AssertionError, expect } from 'chai';
2021
import { compareHeaders } from './compare-headers';
2122

2223
describe('compareHeaders', () => {

packages/installations/src/testing/setup.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { root } from '@firebase/util';
1819
import { use } from 'chai';
1920
import * as chaiAsPromised from 'chai-as-promised';
2021
import { restore } from 'sinon';
2122
import * as sinonChai from 'sinon-chai';
2223
import { clear } from '../helpers/idb-manager';
2324

25+
root.__VERSION__ = '__VERSION__';
26+
2427
use(chaiAsPromised);
2528
use(sinonChai);
2629

packages/installations/src/util/sleep.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../testing/setup';
19+
1820
import { expect } from 'chai';
1921
import { SinonFakeTimers, useFakeTimers } from 'sinon';
20-
import '../testing/setup';
2122
import { sleep } from './sleep';
2223

2324
describe('sleep', () => {

packages/performance/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"scripts": {
1414
"build": "rollup -c",
1515
"dev": "rollup -c -w",
16-
"test": "run-p test:browser",
17-
"test:browser": "karma start --single-run",
16+
"test": "karma start --single-run",
1817
"test:debug": "karma start --browsers=Chrome --auto-watch",
1918
"prepare": "yarn build",
2019
"prettier": "prettier --write '{src,test}/**/*.{js,ts}'"

packages/performance/src/controllers/perf.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../../test/setup';
19+
1820
import { expect } from 'chai';
1921
import { PerformanceController } from '../controllers/perf';
2022
import { Trace } from '../resources/trace';

packages/performance/src/resources/network_request.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { stub, restore } from 'sinon';
18+
import '../../test/setup';
19+
20+
import { stub } from 'sinon';
1921
import { createNetworkRequestEntry } from '../../src/resources/network_request';
2022
import { expect } from 'chai';
2123
import { Api } from '../services/api_service';
2224
import * as perfLogger from '../services/perf_logger';
2325
import { setupApi } from '../services/api_service';
24-
import '../../test/setup';
2526

2627
describe('Firebase Performance > network_request', () => {
2728
setupApi(window);
@@ -31,10 +32,6 @@ describe('Firebase Performance > network_request', () => {
3132
stub(perfLogger, 'logNetworkRequest');
3233
});
3334

34-
afterEach(() => {
35-
restore();
36-
});
37-
3835
describe('#createNetworkRequestEntry', () => {
3936
it('logs network request when all required fields present', () => {
4037
const PERFORMANCE_ENTRY = ({

packages/performance/src/resources/trace.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { spy, stub, restore } from 'sinon';
18+
import '../../test/setup';
19+
20+
import { spy, stub } from 'sinon';
1921
import { Trace } from '../resources/trace';
2022
import { expect } from 'chai';
2123
import { Api } from '../services/api_service';
2224
import * as perfLogger from '../services/perf_logger';
2325
import { setupApi } from '../services/api_service';
24-
import '../../test/setup';
2526

2627
describe('Firebase Performance > trace', () => {
2728
setupApi(window);
@@ -36,10 +37,6 @@ describe('Firebase Performance > trace', () => {
3637
trace = createTrace();
3738
});
3839

39-
afterEach(() => {
40-
restore();
41-
});
42-
4340
describe('#start', () => {
4441
beforeEach(() => {
4542
trace.start();

packages/performance/src/services/api_service.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../../test/setup';
19+
1820
import { stub } from 'sinon';
1921
import { expect } from 'chai';
2022
import { Api, setupApi } from './api_service';
21-
import '../../test/setup';
2223

2324
describe('Firebase Performance > api_service', () => {
2425
const PAGE_URL = 'http://www.test.com/abcd?a=2';

packages/performance/src/services/iid_service.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../../test/setup';
19+
1820
import { stub } from 'sinon';
1921
import { expect } from 'chai';
2022
import { SettingsService } from './settings_service';
@@ -25,7 +27,6 @@ import {
2527
getAuthTokenPromise
2628
} from './iid_service';
2729
import { FirebaseApp } from '@firebase/app-types';
28-
import '../../test/setup';
2930

3031
describe('Firebase Perofmrance > iid_service', () => {
3132
const IID = 'fid';

packages/performance/src/services/initialization_service.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../../test/setup';
19+
1820
import { stub } from 'sinon';
1921
import { expect } from 'chai';
2022
import {
@@ -24,7 +26,6 @@ import {
2426
import { setupApi } from './api_service';
2527
import { SettingsService } from './settings_service';
2628
import { FirebaseApp } from '@firebase/app-types';
27-
import '../../test/setup';
2829

2930
describe('Firebase Perofmrance > initialization_service', () => {
3031
const IID = 'fid';

packages/performance/src/services/oob_resources_service.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../../test/setup';
19+
1820
import {
1921
spy,
2022
stub,
@@ -29,7 +31,6 @@ import * as iidService from './iid_service';
2931
import { setupOobResources } from './oob_resources_service';
3032
import { createNetworkRequestEntry } from '../resources/network_request';
3133
import { Trace } from '../resources/trace';
32-
import '../../test/setup';
3334

3435
describe('Firebase Performance > oob_resources_service', () => {
3536
const MOCK_ID = 'idasdfsffe';

packages/performance/src/services/perf_logger.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import '../../test/setup';
19+
1820
import { stub, SinonStub, useFakeTimers, SinonFakeTimers } from 'sinon';
1921
import { Trace } from '../resources/trace';
2022
import { LogHandler, Logger, LogLevel } from '@firebase/logger';
@@ -27,7 +29,6 @@ import { FirebaseApp } from '@firebase/app-types';
2729
import * as initializationService from './initialization_service';
2830
import * as attributeUtils from '../utils/attributes_utils';
2931
import { createNetworkRequestEntry } from '../resources/network_request';
30-
import '../../test/setup';
3132

3233
describe('Performance Monitoring > perf_logger', () => {
3334
const IID = 'idasdfsffe';

packages/performance/src/services/remote_config_service.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
18+
import '../../test/setup';
19+
1720
import { stub, SinonStub, useFakeTimers, SinonFakeTimers } from 'sinon';
1821
import { expect } from 'chai';
1922
import { SettingsService } from './settings_service';
@@ -22,7 +25,6 @@ import { setupApi } from './api_service';
2225
import * as iidService from './iid_service';
2326
import { getConfig } from './remote_config_service';
2427
import { FirebaseApp } from '@firebase/app-types';
25-
import '../../test/setup';
2628

2729
describe('Performance Monitoring > remote_config_service', () => {
2830
const IID = 'asd123';

0 commit comments

Comments
 (0)