@@ -286,11 +286,11 @@ describe('Pagination component', () => {
286286
287287 changePage ( testFixture , 3 ) ;
288288 tick ( ) ;
289- expect ( paginationService . updateRoute ) . toHaveBeenCalledWith ( 'test' , Object . assign ( { page : 3 } ) , { } , false ) ;
289+ expect ( paginationService . updateRoute ) . toHaveBeenCalledWith ( 'test' , Object . assign ( { page : 3 , pageSize : 10 } ) , { } , false ) ;
290290
291291 changePage ( testFixture , 0 ) ;
292292 tick ( ) ;
293- expect ( paginationService . updateRoute ) . toHaveBeenCalledWith ( 'test' , Object . assign ( { page : 2 } ) , { } , false ) ;
293+ expect ( paginationService . updateRoute ) . toHaveBeenCalledWith ( 'test' , Object . assign ( { page : 2 , pageSize : 10 } ) , { } , false ) ;
294294 } ) ) ;
295295
296296 it ( 'should set correct pageSize route parameters' , fakeAsync ( ( ) => {
@@ -389,6 +389,35 @@ describe('Pagination component', () => {
389389 expect ( next ) . toBeTruthy ( ) ;
390390 } ) ;
391391 } ) ;
392+
393+ it ( 'emits pageChange event with the correct page number' , fakeAsync ( ( ) => {
394+ spyOn ( testComp , 'pageChanged' ) ;
395+ const paginationComponent : PaginationComponent = testFixture . debugElement . query ( By . css ( 'ds-pagination' ) ) . references . p ;
396+
397+ paginationComponent . doPageChange ( 2 ) ;
398+ tick ( ) ;
399+
400+ expect ( testComp . pageChanged ) . toHaveBeenCalledWith ( 2 ) ;
401+ } ) ) ;
402+
403+ it ( 'updates query params with the correct page and pageSize' , fakeAsync ( ( ) => {
404+ const paginationComponent : PaginationComponent = testFixture . debugElement . query ( By . css ( 'ds-pagination' ) ) . references . p ;
405+
406+ paginationComponent . doPageChange ( 3 ) ;
407+ tick ( ) ;
408+
409+ expect ( paginationService . updateRoute ) . toHaveBeenCalledWith ( 'test' , { page : 3 , pageSize : 10 } , { } , false ) ;
410+ } ) ) ;
411+
412+ it ( 'handles undefined pageSize gracefully' , fakeAsync ( ( ) => {
413+ const paginationComponent : PaginationComponent = testFixture . debugElement . query ( By . css ( 'ds-pagination' ) ) . references . p ;
414+
415+ currentPagination . next ( Object . assign ( new PaginationComponentOptions ( ) , pagination , { pageSize : undefined } ) ) ;
416+ paginationComponent . doPageChange ( 1 ) ;
417+ tick ( ) ;
418+
419+ expect ( paginationService . updateRoute ) . toHaveBeenCalledWith ( 'test' , { page : 1 , pageSize : undefined } , { } , false ) ;
420+ } ) ) ;
392421 } ) ;
393422
394423} ) ;
0 commit comments