Skip to content

Commit f6764b7

Browse files
committed
[DURACOM-327] fix tests
1 parent 29a194b commit f6764b7

4 files changed

Lines changed: 28 additions & 19 deletions

File tree

src/app/access-control/epeople-registry/epeople-registry.component.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,16 @@ describe('EPeopleRegistryComponent', () => {
7171
let authorizationService: AuthorizationDataService;
7272
let modalService: NgbModal;
7373
let paginationService: PaginationServiceStub;
74+
let activeEPerson = null;
7475

7576
beforeEach(waitForAsync(async () => {
7677
jasmine.getEnv().allowRespy(true);
7778
mockEPeople = [EPersonMock, EPersonMock2];
78-
epeopleRegistryServiceStub = jasmine.createSpyObj('', {
79-
getActiveEPerson: of(null),
80-
});
79+
epeopleRegistryServiceStub = {
80+
getActiveEPerson(): Observable<EPerson> {
81+
return of(activeEPerson);
82+
},
83+
};
8184
ePersonDataServiceStub = {
8285
activeEPerson: null,
8386
allEpeople: mockEPeople,
@@ -134,10 +137,10 @@ describe('EPeopleRegistryComponent', () => {
134137
return of(true);
135138
},
136139
editEPerson(ePerson: EPerson) {
137-
this.activeEPerson = ePerson;
140+
activeEPerson = ePerson;
138141
},
139142
cancelEditEPerson() {
140-
this.activeEPerson = null;
143+
activeEPerson = null;
141144
},
142145
clearEPersonRequests(): void {
143146
// empty

src/app/access-control/epeople-registry/eperson-form/eperson-form.component.spec.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import { createPaginatedList } from '../../../shared/testing/utils.test';
6464
import { FollowLinkConfig } from '../../../shared/utils/follow-link-config.model';
6565
import { HasNoValuePipe } from '../../../shared/utils/has-no-value.pipe';
6666
import { EPeopleRegistryComponent } from '../epeople-registry.component';
67+
import { EpeopleRegistryService } from '../epeople-registry.service';
6768
import { EPersonFormComponent } from './eperson-form.component';
6869
import { 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();

src/app/entity-groups/research-entities/submission/item-list-elements/person/person-search-result-list-submission-element.component.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { DefaultChangeAnalyzer } from '@core/data/default-change-analyzer.servic
1919
import { DSOChangeAnalyzer } from '@core/data/dso-change-analyzer.service';
2020
import { ItemDataService } from '@core/data/item-data.service';
2121
import { buildPaginatedList } from '@core/data/paginated-list.model';
22-
import { RelationshipDataService } from '@core/data/relationship-data.service';
2322
import { RemoteData } from '@core/data/remote-data';
2423
import { Bitstream } from '@core/shared/bitstream.model';
2524
import { HALEndpointService } from '@core/shared/hal-endpoint.service';
@@ -233,7 +232,7 @@ describe('PersonSearchResultListElementSubmissionComponent', () => {
233232
imports: [TruncatePipe, PersonSearchResultListSubmissionElementComponent],
234233
providers: [
235234
{ provide: TruncatableService, useValue: {} },
236-
{ provide: RelationshipDataService, useValue: mockNameVariantService },
235+
{ provide: NameVariantService, useValue: mockNameVariantService },
237236
{ provide: TranslateService, useValue: translateServiceStub },
238237
{ provide: NgbModal, useValue: {} },
239238
{ provide: ItemDataService, useValue: {} },

src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ import {
99
waitForAsync,
1010
} from '@angular/core/testing';
1111
import { By } from '@angular/platform-browser';
12-
import { RouterTestingModule } from '@angular/router/testing';
12+
import { provideRouter } from '@angular/router';
1313
import { RemoteDataBuildService } from '@core/cache/builders/remote-data-build.service';
1414
import { ExternalSourceDataService } from '@core/data/external-source-data.service';
1515
import { LookupRelationService } from '@core/data/lookup-relation.service';
16-
import { RelationshipDataService } from '@core/data/relationship-data.service';
1716
import { Collection } from '@core/shared/collection.model';
1817
import { ExternalSource } from '@core/shared/external-source.model';
1918
import { Item } from '@core/shared/item.model';
@@ -41,6 +40,7 @@ import { PaginatedSearchOptions } from '../../../../search/models/paginated-sear
4140
import { createPaginatedList } from '../../../../testing/utils.test';
4241
import { RelationshipOptions } from '../../models/relationship-options.model';
4342
import { DsDynamicLookupRelationModalComponent } from './dynamic-lookup-relation-modal.component';
43+
import { NameVariantService } from './name-variant.service';
4444
import {
4545
AddRelationshipAction,
4646
RemoveRelationshipAction,
@@ -124,8 +124,9 @@ describe('DsDynamicLookupRelationModalComponent', () => {
124124
beforeEach(waitForAsync(() => {
125125
init();
126126
TestBed.configureTestingModule({
127-
imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([]), NgbModule, DsDynamicLookupRelationModalComponent, BtnDisabledDirective],
127+
imports: [TranslateModule.forRoot(), NgbModule, DsDynamicLookupRelationModalComponent, BtnDisabledDirective],
128128
providers: [
129+
provideRouter(([])),
129130
{
130131
provide: SearchConfigurationService, useValue: {
131132
paginatedSearchOptions: of(pSearchOptions),
@@ -137,7 +138,7 @@ describe('DsDynamicLookupRelationModalComponent', () => {
137138
provide: SelectableListService, useValue: selectableListService,
138139
},
139140
{
140-
provide: RelationshipDataService, useValue: { getNameVariant: () => of(nameVariant) },
141+
provide: NameVariantService, useValue: { getNameVariant: () => of(nameVariant) },
141142
},
142143
{ provide: RemoteDataBuildService, useValue: rdbService },
143144
{

0 commit comments

Comments
 (0)