Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unhandled Promise rejection warning #556

Merged
merged 2 commits into from
Feb 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions dev/system-test/firestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const version = require('../../package.json').version;
class DeferredPromise<T> {
resolve: Function;
reject: Function;
promise: Promise<T>;
promise: Promise<T>|null;

constructor() {
this.resolve = () => {
Expand All @@ -33,8 +33,7 @@ class DeferredPromise<T> {
this.reject = () => {
throw new Error('DeferredPromise.reject has not been initialized');
};
this.promise =
Promise.reject('DeferredPromise.promise has not been initialized');
this.promise = null;
}
}

Expand Down Expand Up @@ -666,8 +665,7 @@ describe('DocumentReference class', () => {
});

describe('watch', () => {
const currentDeferred = new DeferredPromise();

const currentDeferred = new DeferredPromise<DocumentSnapshot>();

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

function waitForSnapshot(): Promise<DocumentSnapshot> {
return currentDeferred.promise.then(snapshot => {
return currentDeferred.promise!.then(snapshot => {
resetPromise();
return snapshot as DocumentSnapshot;
});
Expand Down Expand Up @@ -1187,7 +1185,7 @@ describe('Query class', () => {
}

function waitForSnapshot(): Promise<QuerySnapshot> {
return currentDeferred.promise.then(snapshot => {
return currentDeferred.promise!.then(snapshot => {
resetPromise();
return snapshot;
});
Expand Down