Skip to content

Commit

Permalink
chore(examples): add typescript example of get with where - #396
Browse files Browse the repository at this point in the history
  • Loading branch information
prescottprue committed Dec 2, 2021
1 parent 2dbecfe commit 39e6729
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions examples/typescript/cypress/integration/Firestore.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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;
});
});

Expand All @@ -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', () => {
Expand Down

0 comments on commit 39e6729

Please sign in to comment.