mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-24 04:24:52 +08:00
[tests][firestore] add collection SnapshotError tests
This commit is contained in:
@@ -7,6 +7,10 @@ const {
|
||||
TEST_COLLECTION_NAME_DYNAMIC,
|
||||
} = TestHelpers.firestore;
|
||||
|
||||
function getSnapshotErrorClass() {
|
||||
return jet.require('src/modules/firestore/SnapshotError');
|
||||
}
|
||||
|
||||
describe('firestore()', () => {
|
||||
describe('CollectionReference', () => {
|
||||
describe('onSnapshot()', () => {
|
||||
@@ -431,6 +435,36 @@ describe('firestore()', () => {
|
||||
unsubscribe();
|
||||
});
|
||||
|
||||
it('snapshot error returns instance of SnapshotError', () => {
|
||||
let unsubscribe;
|
||||
const { reject, resolve, promise } = Promise.defer();
|
||||
const collection = firebase
|
||||
.firestore()
|
||||
.collection('blocked-collection');
|
||||
|
||||
const observer = {
|
||||
next: () => {
|
||||
unsubscribe();
|
||||
reject(new Error('Did not error!'));
|
||||
},
|
||||
error: snapshotError => {
|
||||
snapshotError.should.be.instanceOf(getSnapshotErrorClass());
|
||||
snapshotError.code.should.be.a.String();
|
||||
snapshotError.path.should.be.a.String();
|
||||
snapshotError.appName.should.be.a.String();
|
||||
snapshotError.message.should.be.a.String();
|
||||
snapshotError.nativeErrorMessage.should.be.a.String();
|
||||
snapshotError.appName.should.equal('[DEFAULT]');
|
||||
snapshotError.path.should.equal('blocked-collection');
|
||||
snapshotError.code.should.equal('firestore/permission-denied');
|
||||
resolve();
|
||||
},
|
||||
};
|
||||
|
||||
unsubscribe = collection.onSnapshot(observer);
|
||||
return promise;
|
||||
});
|
||||
|
||||
it('errors when invalid parameters supplied', async () => {
|
||||
const colRef = firebase
|
||||
.firestore()
|
||||
|
||||
Reference in New Issue
Block a user