@@ -23,6 +23,13 @@ import { FindListOptions } from './find-list-options.model';
2323import { testSearchDataImplementation } from './base/search-data.spec' ;
2424import { MetadataValue } from '../shared/metadata.models' ;
2525import { MetadataRepresentationType } from '../shared/metadata-representation/metadata-representation.model' ;
26+ import { TestBed } from '@angular/core/testing' ;
27+ import { ItemDataService } from './item-data.service' ;
28+ import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service' ;
29+ import { HALEndpointService } from '../shared/hal-endpoint.service' ;
30+ import { PAGINATED_RELATIONS_TO_ITEMS_OPERATOR } from '../../item-page/simple/item-types/shared/item-relationships-utils' ;
31+ import { Store } from '@ngrx/store' ;
32+ import { provideMockStore } from '@ngrx/store/testing' ;
2633
2734describe ( 'RelationshipDataService' , ( ) => {
2835 let service : RelationshipDataService ;
@@ -128,18 +135,6 @@ describe('RelationshipDataService', () => {
128135 findByHref : createSuccessfulRemoteDataObject$ ( relatedItems [ 0 ] )
129136 } ) ;
130137
131- function initTestService ( ) {
132- return new RelationshipDataService (
133- requestService ,
134- rdbService ,
135- halService ,
136- objectCache ,
137- itemService ,
138- null ,
139- jasmine . createSpy ( 'paginatedRelationsToItems' ) . and . returnValue ( ( v ) => v ) ,
140- ) ;
141- }
142-
143138 const getRequestEntry$ = ( successful : boolean ) => {
144139 return observableOf ( {
145140 response : { isSuccessful : successful , payload : relationships } as any
@@ -148,11 +143,25 @@ describe('RelationshipDataService', () => {
148143
149144 beforeEach ( ( ) => {
150145 requestService = getMockRequestService ( getRequestEntry$ ( true ) ) ;
151- service = initTestService ( ) ;
146+
147+ TestBed . configureTestingModule ( {
148+ providers : [
149+ { provide : RequestService , useValue : requestService } ,
150+ { provide : RemoteDataBuildService , useValue : rdbService } ,
151+ { provide : HALEndpointService , useValue : halService } ,
152+ { provide : ObjectCacheService , useValue : objectCache } ,
153+ { provide : ItemDataService , useValue : itemService } ,
154+ { provide : RequestService , useValue : requestService } ,
155+ { provide : PAGINATED_RELATIONS_TO_ITEMS_OPERATOR , useValue : jasmine . createSpy ( 'paginatedRelationsToItems' ) . and . returnValue ( ( v ) => v ) } ,
156+ { provide : Store , useValue : provideMockStore ( ) } ,
157+ RelationshipDataService ,
158+ ] ,
159+ } ) ;
160+ service = TestBed . inject ( RelationshipDataService ) ;
152161 } ) ;
153162
154163 describe ( 'composition' , ( ) => {
155- const initService = ( ) => new RelationshipDataService ( null , null , null , null , null , null , null ) ;
164+ const initService = ( ) => new RelationshipDataService ( null , null , null , null , null , null , null , null ) ;
156165
157166 testSearchDataImplementation ( initService ) ;
158167 } ) ;
0 commit comments