Merge remote-tracking branch 'origin/master'

This commit is contained in:
Salakar 2017-11-08 08:07:18 +00:00
commit 6811158aab
3 changed files with 85 additions and 13 deletions

View File

@ -150,7 +150,7 @@ PODS:
- React/Core
- React/fishhook
- React/RCTBlob
- RNFirebase (3.1.0-alpha.1):
- RNFirebase (3.1.0):
- React
- yoga (0.49.1.React)
@ -176,11 +176,11 @@ DEPENDENCIES:
EXTERNAL SOURCES:
React:
:path: ../node_modules/react-native
:path: "../node_modules/react-native"
RNFirebase:
:path: ./../../
:path: "./../../"
yoga:
:path: ../node_modules/react-native/ReactCommon/yoga
:path: "../node_modules/react-native/ReactCommon/yoga"
SPEC CHECKSUMS:
BoringSSL: 19083b821ef3ae0f758fae15482e183003b1e265
@ -199,7 +199,7 @@ SPEC CHECKSUMS:
FirebaseStorage: 0cca42d9b889a0227c3a50121f45a4469fc9eb27
Google-Mobile-Ads-SDK: ed8004a7265b424568dc84f3d2bbe3ea3fff958f
GoogleToolboxForMac: 8e329f1b599f2512c6b10676d45736bcc2cbbeb0
gRPC: 07788969b862af21491908f82b83d17ac08c94cd
gRPC: '07788969b862af21491908f82b83d17ac08c94cd'
gRPC-Core: f707ade59c559fe718e27713189607d03b15f571
gRPC-ProtoRPC: de7505e493a9d1b6b96c8ea8f976c73100fdf53f
gRPC-RxLibrary: 17b9699beb0a838b95b57832244f9ead18e66777
@ -208,9 +208,9 @@ SPEC CHECKSUMS:
nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
Protobuf: 03eef2ee0b674770735cf79d9c4d3659cf6908e8
React: cf892fb84b7d06bf5fea7f328e554c6dcabe85ee
RNFirebase: 0467ca8122b9257acd7f1bb6de1670d9fd51cede
RNFirebase: a76befd482c5e84df7f69893358abda498ee9f76
yoga: 3abf02d6d9aeeb139b4c930eb1367feae690a35a
PODFILE CHECKSUM: b5674be55653f5dda937c8b794d0479900643d45
COCOAPODS: 1.3.1
COCOAPODS: 1.2.1

View File

@ -500,9 +500,12 @@ function collectionReferenceTests({ describe, it, context, firebase, before, aft
});
});
});
});
it('correctly handles limit', async () => {
const collectionTests = firebase.native.firestore().collection('collection-tests2');
context('limit', () => {
let collectionTests;
before(async () => {
collectionTests = firebase.native.firestore().collection('collection-tests2');
await Promise.all([
collectionTests.doc('col1').set(COL_1),
collectionTests.doc('col2').set({ ...COL_1, daz: 234 }),
@ -510,7 +513,9 @@ function collectionReferenceTests({ describe, it, context, firebase, before, aft
collectionTests.doc('col4').set({ ...COL_1, daz: 234 }),
collectionTests.doc('col5').set({ ...COL_1, daz: 234 }),
]);
});
it('correctly works with get()', async () => {
return collectionTests.limit(3)
.get()
.then((querySnapshot) => {
@ -518,6 +523,33 @@ function collectionReferenceTests({ describe, it, context, firebase, before, aft
return cleanCollection(collectionTests);
});
});
it('correctly works with onSnapshot()', async () => {
const collectionRef = collectionTests.limit(3);
const callback = sinon.spy();
// Test
let unsubscribe;
await new Promise((resolve2) => {
unsubscribe = collectionRef.onSnapshot((snapshot) => {
callback(snapshot.size);
resolve2();
});
});
// Assertions
callback.should.be.calledWith(3);
// Tear down
unsubscribe();
});
after(() => {
return cleanCollection(collectionTests);
});
});
context('cursors', () => {
@ -526,10 +558,10 @@ function collectionReferenceTests({ describe, it, context, firebase, before, aft
collectionTests = firebase.native.firestore().collection('collection-tests2');
await Promise.all([
collectionTests.doc('col1').set({ ...COL_1, foo: 'bar0' }),
collectionTests.doc('col2').set({ ...COL_1, foo: 'bar1', daz: 234, timestamp: new Date(2017, 2, 11, 10, 0, 0) }),
collectionTests.doc('col3').set({ ...COL_1, foo: 'bar2', daz: 345, timestamp: new Date(2017, 2, 12, 10, 0, 0) }),
collectionTests.doc('col4').set({ ...COL_1, foo: 'bar3', daz: 456, timestamp: new Date(2017, 2, 13, 10, 0, 0) }),
collectionTests.doc('col5').set({ ...COL_1, foo: 'bar4', daz: 567, timestamp: new Date(2017, 2, 14, 10, 0, 0) }),
collectionTests.doc('col2').set({ ...COL_1, foo: 'bar1', daz: 234, object: { daz: 234 }, timestamp: new Date(2017, 2, 11, 10, 0, 0) }),
collectionTests.doc('col3').set({ ...COL_1, foo: 'bar2', daz: 345, object: { daz: 345 }, timestamp: new Date(2017, 2, 12, 10, 0, 0) }),
collectionTests.doc('col4').set({ ...COL_1, foo: 'bar3', daz: 456, object: { daz: 456 }, timestamp: new Date(2017, 2, 13, 10, 0, 0) }),
collectionTests.doc('col5').set({ ...COL_1, foo: 'bar4', daz: 567, object: { daz: 567 }, timestamp: new Date(2017, 2, 14, 10, 0, 0) }),
]);
});
@ -737,6 +769,43 @@ function collectionReferenceTests({ describe, it, context, firebase, before, aft
});
});
context('onSnapshot()', () => {
it('gets called correctly', async () => {
const collectionRef = collectionTests.orderBy('object.daz').endAt(345);
const newDocValue = { ...COL_1, object: { daz: 346 } };
const callback = sinon.spy();
// Test
let unsubscribe;
await new Promise((resolve2) => {
unsubscribe = collectionRef.onSnapshot((snapshot) => {
callback(snapshot.docs.map(doc => doc.data().daz));
resolve2();
});
});
callback.should.be.calledWith([123, 234, 345]);
const docRef = firebase.native.firestore().doc('collection-tests2/col1');
await docRef.set(newDocValue);
await new Promise((resolve2) => {
setTimeout(() => resolve2(), 5);
});
// Assertions
callback.should.be.calledWith([234, 345]);
callback.should.be.calledTwice();
// Tear down
unsubscribe();
});
});
after(() => {
return cleanCollection(collectionTests);
});

View File

@ -16,6 +16,9 @@ export const COL_1 = {
gaz: 12.1234567,
geopoint: new firebase.native.firestore.GeoPoint(0, 0),
naz: null,
object: {
daz: 123,
},
timestamp: new Date(2017, 2, 10, 10, 0, 0),
};