Skip to content

Commit

Permalink
test: adding simple test for custom queries
Browse files Browse the repository at this point in the history
  • Loading branch information
wovalle committed May 30, 2021
1 parent 2a98b9a commit a6fe499
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/BaseFirestoreRepository.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,27 @@ describe('BaseFirestoreRepository', () => {
expect(list.length).toEqual(2);
});

it('must filter with customQuery', async () => {
const list = await bandRepository
.customQuery(async (_, col) => {
return col.where('id', '==', 'porcupine-tree');
})
.find();
expect(list[0].name).toEqual('Porcupine Tree');
});

it('must mutate query with customQuery', async () => {
const list = await bandRepository
.whereGreaterOrEqualThan(b => b.formationYear, 1983)
.orderByAscending(p => p.name) // to make it deterministic
.customQuery(async q => {
return q.limit(1);
})
.find();

expect(list[0].name).toEqual('Porcupine Tree');
});

it('should throw with whereArrayContainsAny and more than 10 items in val array', async () => {
expect(async () => {
await bandRepository
Expand Down

0 comments on commit a6fe499

Please sign in to comment.