diff --git a/src/BaseFirestoreRepository.spec.ts b/src/BaseFirestoreRepository.spec.ts index 405f7af..ac75d3f 100644 --- a/src/BaseFirestoreRepository.spec.ts +++ b/src/BaseFirestoreRepository.spec.ts @@ -145,75 +145,75 @@ describe('BaseFirestoreRepository', () => { }); }); - describe('orderByDescending', () => { - it('must order repository objects', async () => { - const bands = await bandRepository.orderByDescending('formationYear').find(); - expect(bands[0].id).toEqual('porcupine-tree'); - }); + describe('orderByDescending', () => { + it('must order repository objects', async () => { + const bands = await bandRepository.orderByDescending('formationYear').find(); + expect(bands[0].id).toEqual('porcupine-tree'); + }); - it('must order the objects in a subcollection', async () => { - const pt = await bandRepository.findById('porcupine-tree'); - const albumsSubColl = pt.albums; - const discographyNewestFirst = await albumsSubColl.orderByDescending('releaseDate').find(); - expect(discographyNewestFirst[0].id).toEqual('fear-blank-planet'); - }); + it('must order the objects in a subcollection', async () => { + const pt = await bandRepository.findById('porcupine-tree'); + const albumsSubColl = pt.albums; + const discographyNewestFirst = await albumsSubColl.orderByDescending('releaseDate').find(); + expect(discographyNewestFirst[0].id).toEqual('fear-blank-planet'); + }); - it('must be chainable with where* filters', async () => { - const pt = await bandRepository.findById('porcupine-tree'); - const albumsSubColl = pt.albums; - const discographyNewestFirst = await albumsSubColl - .whereGreaterOrEqualThan('releaseDate', new Date('2001-01-01')) - .orderByDescending('releaseDate') - .find(); - expect(discographyNewestFirst[0].id).toEqual('fear-blank-planet'); - }); + it('must be chainable with where* filters', async () => { + const pt = await bandRepository.findById('porcupine-tree'); + const albumsSubColl = pt.albums; + const discographyNewestFirst = await albumsSubColl + .whereGreaterOrEqualThan('releaseDate', new Date('2001-01-01')) + .orderByDescending('releaseDate') + .find(); + expect(discographyNewestFirst[0].id).toEqual('fear-blank-planet'); + }); - it('must be chainable with limit', async () => { - const bands = await bandRepository.orderByDescending('formationYear').limit(2).find(); - const lastBand = bands[bands.length - 1]; - expect(lastBand.id).toEqual('red-hot-chili-peppers'); - }); + it('must be chainable with limit', async () => { + const bands = await bandRepository.orderByDescending('formationYear').limit(2).find(); + const lastBand = bands[bands.length - 1]; + expect(lastBand.id).toEqual('red-hot-chili-peppers'); + }); - it('must throw an Error if an orderBy* function is called more than once in the same expression', async () => { - const pt = await bandRepository.findById('porcupine-tree'); - const albumsSubColl = pt.albums; - expect(() => { - albumsSubColl.orderByAscending('releaseDate').orderByDescending('releaseDate'); - }).toThrow(); - }); + it('must throw an Error if an orderBy* function is called more than once in the same expression', async () => { + const pt = await bandRepository.findById('porcupine-tree'); + const albumsSubColl = pt.albums; + expect(() => { + albumsSubColl.orderByAscending('releaseDate').orderByDescending('releaseDate'); + }).toThrow(); + }); - it('must throw an Error if an orderBy* function is called more than once in the same expression descending', async () => { - const pt = await bandRepository.findById('porcupine-tree'); - const albumsSubColl = pt.albums; - expect(() => { - albumsSubColl.orderByDescending('releaseDate').orderByDescending('releaseDate'); - }).toThrow(); - }); + it('must throw an Error if an orderBy* function is called more than once in the same expression descending', async () => { + const pt = await bandRepository.findById('porcupine-tree'); + const albumsSubColl = pt.albums; + expect(() => { + albumsSubColl.orderByDescending('releaseDate').orderByDescending('releaseDate'); + }).toThrow(); + }); - it('must succeed when orderBy* function is called more than once in the same expression with different fields', async () => { - const pt = await bandRepository.findById('porcupine-tree'); - const albumsSubColl = pt.albums; - expect(() => { - albumsSubColl.orderByAscending('releaseDate').orderByDescending('name'); - }).not.toThrow(); - }); + it('must succeed when orderBy* function is called more than once in the same expression with different fields', async () => { + const pt = await bandRepository.findById('porcupine-tree'); + const albumsSubColl = pt.albums; + expect(() => { + albumsSubColl.orderByAscending('releaseDate').orderByDescending('name'); + }).not.toThrow(); + }); - it('must succeed when orderBy* function is called more than once in the same expression with different fields ascending', async () => { - const pt = await bandRepository.findById('porcupine-tree'); - const albumsSubColl = pt.albums; - expect(() => { - albumsSubColl.orderByAscending('releaseDate').orderByAscending('name'); - }).not.toThrow(); - }); + it('must succeed when orderBy* function is called more than once in the same expression with different fields ascending', async () => { + const pt = await bandRepository.findById('porcupine-tree'); + const albumsSubColl = pt.albums; + expect(() => { + albumsSubColl.orderByAscending('releaseDate').orderByAscending('name'); + }).not.toThrow(); + }); - it('must succeed when orderBy* function is called more than once in the same expression with different fields descending', async () => { - const pt = await bandRepository.findById('porcupine-tree'); - const albumsSubColl = pt.albums; - expect(() => { - albumsSubColl.orderByDescending('releaseDate').orderByDescending('name'); - }).not.toThrow(); - }); + it('must succeed when orderBy* function is called more than once in the same expression with different fields descending', async () => { + const pt = await bandRepository.findById('porcupine-tree'); + const albumsSubColl = pt.albums; + expect(() => { + albumsSubColl.orderByDescending('releaseDate').orderByDescending('name'); + }).not.toThrow(); }); + }); describe('findById', () => { it('must find by id', async () => { diff --git a/src/types.ts b/src/types.ts index 26dc974..a6f5413 100644 --- a/src/types.ts +++ b/src/types.ts @@ -64,6 +64,7 @@ export interface ILimitable { export type IQueryBuilder = IQueryable & IOrderable & ILimitable; +// eslint-disable-next-line @typescript-eslint/no-unused-vars export type ICustomQuery = ( query: Query, firestoreColRef: CollectionReference