@@ -35,6 +35,7 @@ import {
3535 PutRequest ,
3636} from './request.models' ;
3737import { RequestService } from './request.service' ;
38+ import { RequestParam } from '../cache/models/request-param.model' ;
3839import objectContaining = jasmine . objectContaining ;
3940
4041describe ( 'BitstreamDataService' , ( ) => {
@@ -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