mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-28 20:25:41 +08:00
A few more firestore tests
This commit is contained in:
@@ -322,7 +322,12 @@ export default class Query {
|
|||||||
// validate.isFieldPath('fieldPath', fieldPath);
|
// validate.isFieldPath('fieldPath', fieldPath);
|
||||||
// validate.isOptionalFieldOrder('directionStr', directionStr);
|
// validate.isOptionalFieldOrder('directionStr', directionStr);
|
||||||
|
|
||||||
if (this._queryOptions.startAt || this._queryOptions.endAt) {
|
if (
|
||||||
|
this._queryOptions.startAt ||
|
||||||
|
this._queryOptions.startAfter ||
|
||||||
|
this._queryOptions.endAt ||
|
||||||
|
this._queryOptions.endBefore
|
||||||
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Cannot specify an orderBy() constraint after calling ' +
|
'Cannot specify an orderBy() constraint after calling ' +
|
||||||
'startAt(), startAfter(), endBefore() or endAt().'
|
'startAt(), startAfter(), endBefore() or endAt().'
|
||||||
|
|||||||
@@ -508,6 +508,13 @@ function collectionReferenceTests({
|
|||||||
}).should.throw(
|
}).should.throw(
|
||||||
'Query.onSnapshot failed: Observer.error must be a valid function.'
|
'Query.onSnapshot failed: Observer.error must be a valid function.'
|
||||||
);
|
);
|
||||||
|
(() => {
|
||||||
|
colRef.onSnapshot({
|
||||||
|
next: 'error',
|
||||||
|
});
|
||||||
|
}).should.throw(
|
||||||
|
'Query.onSnapshot failed: Observer.next must be a valid function.'
|
||||||
|
);
|
||||||
(() => {
|
(() => {
|
||||||
colRef.onSnapshot(
|
colRef.onSnapshot(
|
||||||
{
|
{
|
||||||
@@ -1129,6 +1136,56 @@ function collectionReferenceTests({
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
context('orderBy()', () => {
|
||||||
|
it('errors if called after startAt', () => {
|
||||||
|
(() => {
|
||||||
|
firebase.native
|
||||||
|
.firestore()
|
||||||
|
.collection('collections')
|
||||||
|
.startAt({})
|
||||||
|
.orderBy('test');
|
||||||
|
}).should.throw(
|
||||||
|
'Cannot specify an orderBy() constraint after calling startAt(), startAfter(), endBefore() or endAt().'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('errors if called after startAfter', () => {
|
||||||
|
(() => {
|
||||||
|
firebase.native
|
||||||
|
.firestore()
|
||||||
|
.collection('collections')
|
||||||
|
.startAfter({})
|
||||||
|
.orderBy('test');
|
||||||
|
}).should.throw(
|
||||||
|
'Cannot specify an orderBy() constraint after calling startAt(), startAfter(), endBefore() or endAt().'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('errors if called after endBefore', () => {
|
||||||
|
(() => {
|
||||||
|
firebase.native
|
||||||
|
.firestore()
|
||||||
|
.collection('collections')
|
||||||
|
.endBefore({})
|
||||||
|
.orderBy('test');
|
||||||
|
}).should.throw(
|
||||||
|
'Cannot specify an orderBy() constraint after calling startAt(), startAfter(), endBefore() or endAt().'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('errors if called after endAt', () => {
|
||||||
|
(() => {
|
||||||
|
firebase.native
|
||||||
|
.firestore()
|
||||||
|
.collection('collections')
|
||||||
|
.endAt({})
|
||||||
|
.orderBy('test');
|
||||||
|
}).should.throw(
|
||||||
|
'Cannot specify an orderBy() constraint after calling startAt(), startAfter(), endBefore() or endAt().'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
context('onSnapshot()', () => {
|
context('onSnapshot()', () => {
|
||||||
it('gets called correctly', async () => {
|
it('gets called correctly', async () => {
|
||||||
const collectionRef = collectionTests
|
const collectionRef = collectionTests
|
||||||
|
|||||||
@@ -126,6 +126,26 @@ function firestoreTests({ describe, it, context, firebase }) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
context('disableNetwork()', () => {
|
||||||
|
it('should throw an unsupported error', () => {
|
||||||
|
(() => {
|
||||||
|
firebase.native.firestore().disableNetwork();
|
||||||
|
}).should.throw(
|
||||||
|
'firebase.firestore().disableNetwork() is unsupported by the native Firebase SDKs.'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
context('enableNetwork()', () => {
|
||||||
|
it('should throw an unsupported error', () => {
|
||||||
|
(() => {
|
||||||
|
firebase.native.firestore().enableNetwork();
|
||||||
|
}).should.throw(
|
||||||
|
'firebase.firestore().enableNetwork() is unsupported by the native Firebase SDKs.'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
context('enablePersistence()', () => {
|
context('enablePersistence()', () => {
|
||||||
it('should throw an unsupported error', () => {
|
it('should throw an unsupported error', () => {
|
||||||
(() => {
|
(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user