[tests][firestore] start of migrating firestore tests

This commit is contained in:
Salakar 2018-04-12 12:54:29 +01:00
parent 4f5f617de0
commit a3f5b01d67
2 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,42 @@
describe.only('firestore()', () => {
describe('DocumentSnapshot', () => {
before(async () => {
await TestHelpers.firestore.resetTestCollectionDoc();
});
describe('get()', () => {
it('using a dot notated path string', async () => {
const { testCollectionDoc } = TestHelpers.firestore;
const snapshot = await testCollectionDoc().get();
should.equal(snapshot.get('foo'), 'bar');
should.equal(snapshot.get('object.daz'), 123);
should.equal(snapshot.get('nonexistent.object'), undefined);
});
it('using a FieldPath instance', async () => {
const { testCollectionDoc } = TestHelpers.firestore;
const snapshot = await testCollectionDoc().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
);
});
});
});
});

View File

@ -0,0 +1,34 @@
describe('firestore()', () => {
describe('FieldPath', () => {
before(async () => {
await TestHelpers.firestore.resetTestCollectionDoc();
});
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 () => {
const { testCollectionDoc } = TestHelpers.firestore;
const snapshot = await testCollectionDoc().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
);
});
});
});