1+ import { TestBed } from '@angular/core/testing' ;
2+ import { Store } from '@ngrx/store' ;
3+ import { provideMockStore } from '@ngrx/store/testing' ;
14import { of as observableOf } from 'rxjs' ;
25
6+ import { PAGINATED_RELATIONS_TO_ITEMS_OPERATOR } from '../../item-page/simple/item-types/shared/item-relationships-utils' ;
37import { getMockRemoteDataBuildServiceHrefMap } from '../../shared/mocks/remote-data-build.service.mock' ;
48import { getMockRequestService } from '../../shared/mocks/request.service.mock' ;
59import {
@@ -11,7 +15,9 @@ import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-servic
1115import { ObjectCacheServiceStub } from '../../shared/testing/object-cache-service.stub' ;
1216import { createPaginatedList } from '../../shared/testing/utils.test' ;
1317import { followLink } from '../../shared/utils/follow-link-config.model' ;
18+ import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service' ;
1419import { ObjectCacheService } from '../cache/object-cache.service' ;
20+ import { HALEndpointService } from '../shared/hal-endpoint.service' ;
1521import { Item } from '../shared/item.model' ;
1622import { Relationship } from '../shared/item-relationships/relationship.model' ;
1723import { RelationshipType } from '../shared/item-relationships/relationship-type.model' ;
@@ -20,6 +26,7 @@ import { MetadataRepresentationType } from '../shared/metadata-representation/me
2026import { PageInfo } from '../shared/page-info.model' ;
2127import { testSearchDataImplementation } from './base/search-data.spec' ;
2228import { FindListOptions } from './find-list-options.model' ;
29+ import { ItemDataService } from './item-data.service' ;
2330import { buildPaginatedList } from './paginated-list.model' ;
2431import { RelationshipDataService } from './relationship-data.service' ;
2532import { DeleteRequest } from './request.models' ;
@@ -123,18 +130,6 @@ describe('RelationshipDataService', () => {
123130 findByHref : createSuccessfulRemoteDataObject$ ( relatedItems [ 0 ] ) ,
124131 } ) ;
125132
126- function initTestService ( ) {
127- return new RelationshipDataService (
128- requestService ,
129- rdbService ,
130- halService ,
131- objectCache as ObjectCacheService ,
132- itemService ,
133- null ,
134- jasmine . createSpy ( 'paginatedRelationsToItems' ) . and . returnValue ( ( v ) => v ) ,
135- ) ;
136- }
137-
138133 const getRequestEntry$ = ( successful : boolean ) => {
139134 return observableOf ( {
140135 response : { isSuccessful : successful , payload : relationships } as any ,
@@ -143,11 +138,25 @@ describe('RelationshipDataService', () => {
143138
144139 beforeEach ( ( ) => {
145140 requestService = getMockRequestService ( getRequestEntry$ ( true ) ) ;
146- service = initTestService ( ) ;
141+
142+ TestBed . configureTestingModule ( {
143+ providers : [
144+ { provide : RequestService , useValue : requestService } ,
145+ { provide : RemoteDataBuildService , useValue : rdbService } ,
146+ { provide : HALEndpointService , useValue : halService } ,
147+ { provide : ObjectCacheService , useValue : objectCache } ,
148+ { provide : ItemDataService , useValue : itemService } ,
149+ { provide : RequestService , useValue : requestService } ,
150+ { provide : PAGINATED_RELATIONS_TO_ITEMS_OPERATOR , useValue : jasmine . createSpy ( 'paginatedRelationsToItems' ) . and . returnValue ( ( v ) => v ) } ,
151+ { provide : Store , useValue : provideMockStore ( ) } ,
152+ RelationshipDataService ,
153+ ] ,
154+ } ) ;
155+ service = TestBed . inject ( RelationshipDataService ) ;
147156 } ) ;
148157
149158 describe ( 'composition' , ( ) => {
150- const initService = ( ) => new RelationshipDataService ( null , null , null , null , null , null , null ) ;
159+ const initService = ( ) => new RelationshipDataService ( null , null , null , null , null , null , null , null ) ;
151160
152161 testSearchDataImplementation ( initService ) ;
153162 } ) ;
0 commit comments