@@ -2,13 +2,18 @@ import {
22 HttpClient ,
33 HttpHeaders ,
44} from '@angular/common/http' ;
5+ import { waitForAsync } from '@angular/core/testing' ;
56import { Store } from '@ngrx/store' ;
67import {
78 cold ,
89 getTestScheduler ,
910 hot ,
1011} from 'jasmine-marbles' ;
11- import { of as observableOf } from 'rxjs' ;
12+ import {
13+ of as observableOf ,
14+ of ,
15+ } from 'rxjs' ;
16+ import { map } from 'rxjs/operators' ;
1217import { TestScheduler } from 'rxjs/testing' ;
1318
1419import { getMockHrefOnlyDataService } from '../../shared/mocks/href-only-data.service.mock' ;
@@ -151,12 +156,17 @@ describe('WorkspaceitemDataService test', () => {
151156 } ) ;
152157
153158 describe ( 'findByItem' , ( ) => {
154- it ( 'should proxy the call to UpdateDataServiceImpl.findByHref' , ( ) => {
159+ it ( 'should proxy the call to UpdateDataServiceImpl.findByHref' , waitForAsync ( ( ) => {
155160 scheduler . schedule ( ( ) => service . findByItem ( '1234-1234' , true , true , pageInfo ) ) ;
156161 scheduler . flush ( ) ;
157- const searchUrl = service . getIDHref ( 'item' , [ new RequestParam ( 'uuid' , '1234-1234' ) ] ) ;
158- expect ( ( service as any ) . findByHref ) . toHaveBeenCalledWith ( searchUrl , true , true ) ;
159- } ) ;
162+ const searchUrl$ =
163+ of ( 'https://rest.api/rest/api/submission/workspaceitems/search/item' )
164+ . pipe ( map ( href => service . buildHrefFromFindOptions ( href , { searchParams : [ new RequestParam ( 'uuid' , '1234-1234' ) ] } , [ ] ) ) ) ;
165+ searchUrl$ . subscribe ( ( url ) => {
166+ expect ( url ) . toEqual ( 'https://rest.api/rest/api/submission/workspaceitems/search/item?uuid=1234-1234' ) ;
167+ } ) ;
168+ expect ( ( service as any ) . findByHref ) . toHaveBeenCalled ( ) ;
169+ } ) ) ;
160170
161171 it ( 'should return a RemoteData<WorkspaceItem> for the search' , ( ) => {
162172 const result = service . findByItem ( '1234-1234' , true , true , pageInfo ) ;
0 commit comments