From 39e67298b76caa3805d50b4b25c103486d97920f Mon Sep 17 00:00:00 2001 From: Scott Prue Date: Wed, 1 Dec 2021 22:10:32 -0700 Subject: [PATCH] chore(examples): add typescript example of get with where - #396 --- .../cypress/integration/Firestore.spec.ts | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/examples/typescript/cypress/integration/Firestore.spec.ts b/examples/typescript/cypress/integration/Firestore.spec.ts index 275a67db..9738989a 100644 --- a/examples/typescript/cypress/integration/Firestore.spec.ts +++ b/examples/typescript/cypress/integration/Firestore.spec.ts @@ -1,5 +1,9 @@ describe('callFirestore', () => { describe('get', () => { + before(() => { + cy.callFirestore('add', 'projects', { name: 'test' }) + }) + it('should return null for empty collection', () => { cy.callFirestore('get', 'asdf').then(results => { cy.log('results:', results); @@ -8,11 +12,9 @@ describe('callFirestore', () => { }); it('should return documents from collection', () => { - cy.callFirestore('add', 'projects', { name: 'test' }).then(() => { - cy.callFirestore('get', 'projects').then(results => { - cy.log('results:', results); - expect(results).to.exist; - }); + cy.callFirestore('get', 'projects').then(results => { + cy.log('results:', results); + expect(results).to.exist; }); }); @@ -23,6 +25,18 @@ describe('callFirestore', () => { expect(results).to.have.length(1); }); }); + + it('should query with where', () => { + const uniqueName = 'Test Where' + cy.callFirestore('add', 'projects', { name: uniqueName }) + cy.callFirestore('get', 'projects', { + where: ['name', '==', uniqueName], + }).then((results) => { + cy.log('get respond', results); + expect(results).to.exist; + expect(results).to.have.length(1); + }); + }) }) describe('set', () => {