Skip to content

Commit 82eb2cf

Browse files
Remove unhandled Promise rejection warning (#556)
1 parent a78495b commit 82eb2cf

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

dev/system-test/firestore.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const version = require('../../package.json').version;
2424
class DeferredPromise<T> {
2525
resolve: Function;
2626
reject: Function;
27-
promise: Promise<T>;
27+
promise: Promise<T>|null;
2828

2929
constructor() {
3030
this.resolve = () => {
@@ -33,8 +33,7 @@ class DeferredPromise<T> {
3333
this.reject = () => {
3434
throw new Error('DeferredPromise.reject has not been initialized');
3535
};
36-
this.promise =
37-
Promise.reject('DeferredPromise.promise has not been initialized');
36+
this.promise = null;
3837
}
3938
}
4039

@@ -666,8 +665,7 @@ describe('DocumentReference class', () => {
666665
});
667666

668667
describe('watch', () => {
669-
const currentDeferred = new DeferredPromise();
670-
668+
const currentDeferred = new DeferredPromise<DocumentSnapshot>();
671669

672670
function resetPromise() {
673671
currentDeferred.promise = new Promise((resolve, reject) => {
@@ -677,7 +675,7 @@ describe('DocumentReference class', () => {
677675
}
678676

679677
function waitForSnapshot(): Promise<DocumentSnapshot> {
680-
return currentDeferred.promise.then(snapshot => {
678+
return currentDeferred.promise!.then(snapshot => {
681679
resetPromise();
682680
return snapshot as DocumentSnapshot;
683681
});
@@ -1187,7 +1185,7 @@ describe('Query class', () => {
11871185
}
11881186

11891187
function waitForSnapshot(): Promise<QuerySnapshot> {
1190-
return currentDeferred.promise.then(snapshot => {
1188+
return currentDeferred.promise!.then(snapshot => {
11911189
resetPromise();
11921190
return snapshot;
11931191
});

0 commit comments

Comments
 (0)