Skip to content

Commit f558aa0

Browse files
committed
updated performance constructor test
1 parent e012877 commit f558aa0

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,33 @@ describe('Firebase Performance Test', () => {
5050
new PerformanceController(fakeFirebaseApp);
5151
expect(initializationService.getInitializationPromise).not.be.called;
5252
});
53-
it('does not initialize performance if validateIndexedDBOpenable return false', () => {
53+
it('does not initialize performance if validateIndexedDBOpenable return false', async () => {
5454
stub(Api.prototype, 'requiredApisAvailable').returns(true);
55-
stub(FirebaseUtil, 'validateIndexedDBOpenable').returns(
56-
Promise.resolve(false)
57-
);
55+
const validateStub = stub(
56+
FirebaseUtil,
57+
'validateIndexedDBOpenable'
58+
).resolves(false);
5859
stub(initializationService, 'getInitializationPromise');
5960
new PerformanceController(fakeFirebaseApp);
61+
await validateStub;
6062
expect(initializationService.getInitializationPromise).not.be.called;
6163
});
6264

63-
it('does not initialize performance if validateIndexedDBOpenable throws an error', () => {
65+
it('does not initialize performance if validateIndexedDBOpenable throws an error', async () => {
6466
stub(Api.prototype, 'requiredApisAvailable').returns(true);
65-
stub(FirebaseUtil, 'validateIndexedDBOpenable').throws();
67+
const validateStub = stub(
68+
FirebaseUtil,
69+
'validateIndexedDBOpenable'
70+
).rejects();
71+
6672
stub(initializationService, 'getInitializationPromise');
6773
stub(consoleLogger, 'info');
6874
new PerformanceController(fakeFirebaseApp);
69-
expect(initializationService.getInitializationPromise).not.be.called;
70-
expect(consoleLogger.info).to.be.called;
75+
try {
76+
await validateStub;
77+
expect(initializationService.getInitializationPromise).not.be.called;
78+
expect(consoleLogger.info).be.called;
79+
} catch (ignored) {}
7180
});
7281
});
7382

packages/performance/src/controllers/perf.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { validateIndexedDBOpenable } from '@firebase/util';
2626
import { consoleLogger } from '../utils/console_logger';
2727
export class PerformanceController implements FirebasePerformance {
2828
constructor(readonly app: FirebaseApp) {
29-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
3029
if (Api.getInstance().requiredApisAvailable()) {
3130
validateIndexedDBOpenable()
3231
.then(isAvailable => {

0 commit comments

Comments
 (0)