@@ -64,6 +64,7 @@ import { createPaginatedList } from '../../../shared/testing/utils.test';
6464import { FollowLinkConfig } from '../../../shared/utils/follow-link-config.model' ;
6565import { HasNoValuePipe } from '../../../shared/utils/has-no-value.pipe' ;
6666import { EPeopleRegistryComponent } from '../epeople-registry.component' ;
67+ import { EpeopleRegistryService } from '../epeople-registry.service' ;
6768import { EPersonFormComponent } from './eperson-form.component' ;
6869import { ValidateEmailNotTaken } from './validators/email-taken.validator' ;
6970
@@ -74,25 +75,29 @@ describe('EPersonFormComponent', () => {
7475
7576 let mockEPeople ;
7677 let ePersonDataServiceStub : any ;
78+ let epeopleRegistryServiceStub : any ;
7779 let authService : AuthServiceStub ;
7880 let authorizationService : AuthorizationDataService ;
7981 let groupsDataService : GroupDataService ;
8082 let epersonRegistrationService : EpersonRegistrationService ;
8183 let route : ActivatedRouteStub ;
8284 let router : RouterStub ;
85+ let activeEPerson = null ;
8386
8487 let paginationService ;
8588
8689
8790
8891 beforeEach ( waitForAsync ( ( ) => {
8992 mockEPeople = [ EPersonMock , EPersonMock2 ] ;
93+ epeopleRegistryServiceStub = {
94+ getActiveEPerson ( ) : Observable < EPerson > {
95+ return of ( activeEPerson ) ;
96+ } ,
97+ } ;
9098 ePersonDataServiceStub = {
9199 activeEPerson : null ,
92100 allEpeople : mockEPeople ,
93- getActiveEPerson ( ) : Observable < EPerson > {
94- return of ( this . activeEPerson ) ;
95- } ,
96101 searchByScope ( scope : string , query : string , options : FindListOptions = { } ) : Observable < RemoteData < PaginatedList < EPerson > > > {
97102 if ( scope === 'email' ) {
98103 const result = this . allEpeople . find ( ( ePerson : EPerson ) => {
@@ -122,10 +127,10 @@ describe('EPersonFormComponent', () => {
122127 return createSuccessfulRemoteDataObject$ ( ePerson ) ;
123128 } ,
124129 editEPerson ( ePerson : EPerson ) {
125- this . activeEPerson = ePerson ;
130+ activeEPerson = ePerson ;
126131 } ,
127132 cancelEditEPerson ( ) {
128- this . activeEPerson = null ;
133+ activeEPerson = null ;
129134 } ,
130135 clearEPersonRequests ( ) : void {
131136 // empty
@@ -230,6 +235,7 @@ describe('EPersonFormComponent', () => {
230235 ] ,
231236 providers : [
232237 { provide : EPersonDataService , useValue : ePersonDataServiceStub } ,
238+ { provide : EpeopleRegistryService , useValue : epeopleRegistryServiceStub } ,
233239 { provide : GroupDataService , useValue : groupsDataService } ,
234240 { provide : FormBuilderService , useValue : builderService } ,
235241 { provide : NotificationsService , useValue : new NotificationsServiceStub ( ) } ,
@@ -389,7 +395,7 @@ describe('EPersonFormComponent', () => {
389395 } ) ;
390396 describe ( 'without active EPerson' , ( ) => {
391397 beforeEach ( ( ) => {
392- spyOn ( ePersonDataServiceStub , 'getActiveEPerson' ) . and . returnValue ( of ( undefined ) ) ;
398+ spyOn ( epeopleRegistryServiceStub , 'getActiveEPerson' ) . and . returnValue ( of ( undefined ) ) ;
393399 component . onSubmit ( ) ;
394400 fixture . detectChanges ( ) ;
395401 } ) ;
@@ -429,7 +435,7 @@ describe('EPersonFormComponent', () => {
429435 } ,
430436 } ,
431437 } ) ;
432- spyOn ( ePersonDataServiceStub , 'getActiveEPerson' ) . and . returnValue ( of ( expectedWithId ) ) ;
438+ spyOn ( epeopleRegistryServiceStub , 'getActiveEPerson' ) . and . returnValue ( of ( expectedWithId ) ) ;
433439 component . ngOnInit ( ) ;
434440 component . onSubmit ( ) ;
435441 fixture . detectChanges ( ) ;
@@ -486,7 +492,7 @@ describe('EPersonFormComponent', () => {
486492 eperson = EPersonMock ;
487493 component . epersonInitial = eperson ;
488494 component . canDelete$ = of ( true ) ;
489- spyOn ( component . epersonService , 'getActiveEPerson' ) . and . returnValue ( of ( eperson ) ) ;
495+ spyOn ( component . epeopleRegistryService , 'getActiveEPerson' ) . and . returnValue ( of ( eperson ) ) ;
490496 modalService = ( component as any ) . modalService ;
491497 spyOn ( modalService , 'open' ) . and . returnValue ( Object . assign ( { componentInstance : Object . assign ( { response : of ( true ) } ) } ) ) ;
492498 component . ngOnInit ( ) ;
0 commit comments