11import { Observable , of as observableOf } from 'rxjs' ;
22import { CommonModule } from '@angular/common' ;
33import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core' ;
4- import { ComponentFixture , TestBed , waitForAsync } from '@angular/core/testing' ;
4+ import { ComponentFixture , fakeAsync , TestBed , tick , waitForAsync } from '@angular/core/testing' ;
55import { UntypedFormControl , UntypedFormGroup , FormsModule , ReactiveFormsModule , Validators } from '@angular/forms' ;
66import { BrowserModule , By } from '@angular/platform-browser' ;
77import { NgbModule } from '@ng-bootstrap/ng-bootstrap' ;
@@ -30,7 +30,7 @@ import { PaginationServiceStub } from '../../../shared/testing/pagination-servic
3030import { FindListOptions } from '../../../core/data/find-list-options.model' ;
3131import { ValidateEmailNotTaken } from './validators/email-taken.validator' ;
3232import { EpersonRegistrationService } from '../../../core/data/eperson-registration.service' ;
33- import { FollowLinkConfig } from '../../../shared/utils/follow-link-config.model' ;
33+ import { followLink , FollowLinkConfig } from '../../../shared/utils/follow-link-config.model' ;
3434import { ActivatedRoute , Router } from '@angular/router' ;
3535import { RouterStub } from '../../../shared/testing/router.stub' ;
3636import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub' ;
@@ -46,7 +46,7 @@ describe('EPersonFormComponent', () => {
4646 let ePersonDataServiceStub : any ;
4747 let authService : AuthServiceStub ;
4848 let authorizationService : AuthorizationDataService ;
49- let groupsDataService : GroupDataService ;
49+ let groupsDataService : jasmine . SpyObj < GroupDataService > ;
5050 let epersonRegistrationService : EpersonRegistrationService ;
5151 let route : ActivatedRouteStub ;
5252 let router : RouterStub ;
@@ -513,4 +513,15 @@ describe('EPersonFormComponent', () => {
513513 expect ( epersonRegistrationService . registerEmail ) . toHaveBeenCalledWith ( ePersonEmail , null , 'forgot' ) ;
514514 } ) ;
515515 } ) ;
516+
517+ describe ( 'findListByHref functionality' , ( ) => {
518+ it ( 'retrieves groups and object on page change' , fakeAsync ( ( ) => {
519+ component . activeEPerson$ = observableOf ( { _links : { groups : { href : 'groups' } } } as EPerson ) ;
520+
521+ const options = { currentPage : 1 , elementsPerPage : 5 } ;
522+ component . onPageChange ( options . currentPage ) ;
523+ tick ( ) ;
524+ expect ( groupsDataService . findListByHref ) . toHaveBeenCalledWith ( jasmine . anything ( ) , options , undefined , undefined , followLink ( 'object' ) ) ;
525+ } ) ) ;
526+ } ) ;
516527} ) ;
0 commit comments