Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
wovalle committed Nov 11, 2021
1 parent 3732cf1 commit 81c2dd9
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 60 deletions.
120 changes: 60 additions & 60 deletions src/BaseFirestoreRepository.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export interface ILimitable<T extends IEntity> {

export type IQueryBuilder<T extends IEntity> = IQueryable<T> & IOrderable<T> & ILimitable<T>;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export type ICustomQuery<T> = (
query: Query,
firestoreColRef: CollectionReference
Expand Down

0 comments on commit 81c2dd9

Please sign in to comment.