Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add system test, remove async on terminate
- Loading branch information
Brian Chen
committed
Dec 19, 2019
1 parent
2962654
commit 95a82b9
Showing
2 changed files
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,24 @@ describe('Firestore class', () => { | |
expect(docs[1].data()).to.deep.equal({f: 'a'}); | ||
}); | ||
}); | ||
|
||
it('cannot make calls after the client has been terminated', () => { | ||
const ref1 = randomCol.doc('doc1'); | ||
ref1.onSnapshot(snapshot => { | ||
return Promise.reject('onSnapshot() should be called'); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
}); | ||
return firestore | ||
.terminate() | ||
.then(() => { | ||
return ref1.set({foo: 100}); | ||
}) | ||
.then(() => { | ||
Promise.reject('set() should have failed'); | ||
}) | ||
This comment has been minimized.
Sorry, something went wrong.
schmidt-sebastian
Contributor
|
||
.catch(err => { | ||
expect(err.message).to.equal('The client has already been terminated'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('CollectionReference class', () => { | ||
|
Should this be “Shouldn’t be called”?
Do note that this test is racey. It could indeed be called once before terminate() is processed. The saving grace here is that returning a rejected Promise here won’t fail the test - but it will result in a warning about an uncaught Promise. I think the best way to do this is using Mocha’s “done” function that you can invoke with an error once terminate is called.