@@ -16,6 +16,7 @@ import { NotificationsService } from '../../shared/notifications/notifications.s
1616import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub' ;
1717import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model' ;
1818import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service' ;
19+ import { RequestParam } from '../cache/models/request-param.model' ;
1920import { ObjectCacheService } from '../cache/object-cache.service' ;
2021import { Bitstream } from '../shared/bitstream.model' ;
2122import { BitstreamFormat } from '../shared/bitstream-format.model' ;
@@ -176,4 +177,30 @@ describe('BitstreamDataService', () => {
176177 expect ( service . invalidateByHref ) . toHaveBeenCalledWith ( 'fake-bitstream2-self' ) ;
177178 } ) ;
178179 } ) ;
180+
181+ describe ( 'findByItemHandle' , ( ) => {
182+ it ( 'should encode the filename correctly in the search parameters' , ( ) => {
183+ const handle = '123456789/1234' ;
184+ const sequenceId = '5' ;
185+ const filename = 'file with spaces.pdf' ;
186+ const searchParams = [
187+ new RequestParam ( 'handle' , handle ) ,
188+ new RequestParam ( 'sequenceId' , sequenceId ) ,
189+ new RequestParam ( 'filename' , filename ) ,
190+ ] ;
191+ const linksToFollow : FollowLinkConfig < Bitstream > [ ] = [ ] ;
192+
193+ spyOn ( service as any , 'getSearchByHref' ) . and . callThrough ( ) ;
194+
195+ service . getSearchByHref ( 'byItemHandle' , { searchParams } , ...linksToFollow ) . subscribe ( ( href ) => {
196+ expect ( service . getSearchByHref ) . toHaveBeenCalledWith (
197+ 'byItemHandle' ,
198+ { searchParams } ,
199+ ...linksToFollow ,
200+ ) ;
201+
202+ expect ( href ) . toBe ( `${ url } /bitstreams/search/byItemHandle?handle=123456789%2F1234&sequenceId=5&filename=file%20with%20spaces.pdf` ) ;
203+ } ) ;
204+ } ) ;
205+ } ) ;
179206} ) ;
0 commit comments