import { PaginationDirective } from './pagination.directive' ; import { TestBed , ComponentFixture } from '@angular/core/testing' ; import { UserPreferencesService , AppConfigService , PaginationComponent , PaginationModel , CoreTestingModule } from '@alfresco/adf-core' ; import { initialState , LibTestingModule } from '../testing/lib-testing-module' ; import { SharedDirectivesModule } from './shared.directives.module' ; import { TranslateModule } from '@ngx-translate/core' ; import { provideMockStore } from '@ngrx/store/testing' ; describe ( 'PaginationDirective' , ( ) => { let preferences ; let config ; let pagination ; let fixture ; let directive ; beforeEach ( ( ) => { TestBed . configureTestingModule ( { imports : [ TranslateModule . forRoot ( ) , LibTestingModule , SharedDirectivesModule , CoreTestingModule ] , providers : [ provideMockStore ( { initialState } ) ] } ) ; preferences = TestBed . inject ( UserPreferencesService ) ; config = TestBed . inject ( AppConfigService ) ; fixture = TestBed . createComponent ( PaginationComponent ) ; pagination = fixture . componentInstance ; directive = new PaginationDirective ( pagination , preferences , config ) ; } ) ; afterEach ( ( ) => { fixture . destroy ( ) ; directive . ngOnDestroy ( ) ; } ) ; it ( 'should setup supported page sizes from app config' , ( ) => { spyOn ( config , 'get' ) . and . returnValue ( [ 21 , 31 , 41 ] ) ; directive . ngOnInit ( ) ; expect ( pagination . supportedPageSizes ) . toEqual ( [ 21 , 31 , 41 ] ) ; } ) ; it ( 'should update preferences on page size change' , ( ) => { directive . ngOnInit ( ) ; pagination . changePageSize . emit ( new PaginationModel ( { maxItems : 100 } ) ) ; expect ( preferences . paginationSize ) . toBe ( 100 ) ; } ) ; } ) ;