2018-04-13 12:49:03 +00:00
|
|
|
const {
|
|
|
|
COL_DOC_1,
|
|
|
|
COL_DOC_1_PATH,
|
|
|
|
testCollectionDoc,
|
|
|
|
resetTestCollectionDoc,
|
|
|
|
} = TestHelpers.firestore;
|
|
|
|
|
2018-04-12 11:54:29 +00:00
|
|
|
describe('firestore()', () => {
|
|
|
|
describe('FieldPath', () => {
|
|
|
|
before(async () => {
|
2018-04-13 12:49:03 +00:00
|
|
|
await resetTestCollectionDoc(COL_DOC_1_PATH, COL_DOC_1());
|
2018-04-12 11:54:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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();
|
2018-04-12 11:54:29 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|