[#5352] Fix broken pagination if totalItems is missing (#5473)

* [#5352] Fix broken pagination if totalItems is missing. This happens when a search query is executed against Solr and not the DB

* fix lint issues

Co-authored-by: Arik Sidney Guggenheim <ariksidney@outlook.com>
This commit is contained in:
Eugenio Romano
2020-02-21 12:12:28 +00:00
committed by GitHub
parent b7de48c821
commit feebaebd6c
3 changed files with 51 additions and 11 deletions

View File

@@ -347,4 +347,27 @@ describe('PaginationComponent', () => {
});
});
describe('without total items', () => {
beforeEach(() => {
component.pagination = new FakePaginationInput(3, 2, 5);
component.pagination.hasMoreItems = true;
component.pagination.totalItems = undefined;
});
it('has the same, previous page', () => {
expect(component.previous).toBe(1);
});
it('has next page', () => {
expect(component.next).toBe(3);
});
it('has range', () => {
expect(component.range).toEqual([ 26, 50 ]);
});
it('cannot calculate number of pages', () => {
expect(component.pages).toEqual([1]);
});
});
});