Skip to content

Commit

Permalink
Merge branch 'next' into f/bh-90465
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbullhorn authored Oct 3, 2024
2 parents 03ca341 + eda67ee commit bc9d29a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ describe('Elements: NovoDataTablePagination', () => {
component = fixture.debugElement.componentInstance;
}));

describe('Setter: set page()', () => {
beforeEach(() => {
component.pageSize = 25;
component.length = 500;
component.ngOnInit();
spyOn(component, 'updateDisplayedPageSizeOptions').and.callThrough();
});
it('should set displayed pages via updateDisplayedPageSizeOptions function', () => {
component.selectPage(10);
expect(component.page).toEqual(10);
const actualDisplayedPageNumbers1 = component.pages.map((page) => page.number);
expect(actualDisplayedPageNumbers1).toEqual([8, 9, 10, 11, 12]);
component.page = 1;
expect(component.page).toEqual(1);
const actualDisplayedPageNumbers2 = component.pages.map((page) => page.number);
expect(component.updateDisplayedPageSizeOptions).toHaveBeenCalled();
expect(actualDisplayedPageNumbers2).toEqual([1, 2, 3, 4, 5]);
});
});

describe('Method: selectPage()', () => {
beforeEach(() => {
spyOn(component.state, 'checkRetainment');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export class NovoDataTablePagination<T> implements OnInit, OnDestroy {
this.longRangeLabel = this.labels.getRangeText(this.page, this.pageSize, this.length, false);
this.shortRangeLabel = this.labels.getRangeText(this.page, this.pageSize, this.length, true);
this.state.page = this._page;
this.updateDisplayedPageSizeOptions();
}
_page: number = 0;

Expand Down

0 comments on commit bc9d29a

Please sign in to comment.