react-native-firebase/bridge/e2e/firestore/fieldPath.e2e.js

41 lines
1.0 KiB
JavaScript
Raw Normal View History

2018-04-13 12:49:03 +00:00
const {
COL_DOC_1,
COL_DOC_1_PATH,
testCollectionDoc,
resetTestCollectionDoc,
} = TestHelpers.firestore;
describe('firestore()', () => {
describe('FieldPath', () => {
before(async () => {
2018-04-13 12:49:03 +00:00
await resetTestCollectionDoc(COL_DOC_1_PATH, COL_DOC_1());
});
it('documentId() should return a FieldPath', () => {
const documentId = firebase.firestore.FieldPath.documentId();
documentId.should.be.instanceof(firebase.firestore.FieldPath);
});
it('should allow getting values via documentSnapshot.get(FieldPath)', async () => {
2018-04-13 12:49:03 +00:00
const snapshot = await testCollectionDoc(COL_DOC_1_PATH).get();
should.equal(snapshot.get('foo'), 'bar');
should.equal(
snapshot.get(new firebase.firestore.FieldPath('foo')),
'bar'
);
should.equal(
snapshot.get(new firebase.firestore.FieldPath('object', 'daz')),
123
);
should.equal(
snapshot.get(new firebase.firestore.FieldPath('nonexistent', 'object')),
undefined
);
});
});
});