@@ -317,6 +317,31 @@ describe('Pagination component', () => {
317317 expect ( de . nativeElement . classList . contains ( 'pagination-sm' ) ) . toBeTruthy ( ) ;
318318 } ) ;
319319 } ) ;
320+
321+ it ( 'should show surrounding pages when navigating to a later page' , ( ) => {
322+ testComp . collectionSize = 200 ;
323+ testComp . paginationOptions . maxSize = 5 ;
324+ testFixture . detectChanges ( ) ;
325+
326+ currentPagination . next ( Object . assign ( new PaginationComponentOptions ( ) , pagination , { currentPage : 10 } ) ) ;
327+ testFixture . detectChanges ( ) ;
328+
329+ const paginationDe = testFixture . debugElement . query ( By . css ( '.pagination' ) ) ;
330+ const activePage = paginationDe . nativeElement . querySelector ( 'li.active' ) ;
331+ expect ( activePage ) . toBeTruthy ( ) ;
332+ expect ( activePage . textContent . trim ( ) ) . toContain ( '10' ) ;
333+
334+ const allPages = paginationDe . nativeElement . querySelectorAll ( 'li' ) ;
335+ const pageNumbers = Array . from ( allPages ) . map ( ( li : any ) =>
336+ li . textContent . trim ( ) . replace ( / \s + / g, '' ) ,
337+ ) . filter ( t => / ^ \d + $ / . test ( t ) ) ;
338+
339+ expect ( pageNumbers ) . toContain ( '8' ) ;
340+ expect ( pageNumbers ) . toContain ( '9' ) ;
341+ expect ( pageNumbers ) . toContain ( '10' ) ;
342+ expect ( pageNumbers ) . toContain ( '11' ) ;
343+ expect ( pageNumbers ) . toContain ( '12' ) ;
344+ } ) ;
320345 } ) ;
321346
322347 describe ( 'when showPaginator is true' , ( ) => {
0 commit comments