Skip to content

Commit 15f3118

Browse files
msarmietdonohue
authored andcommitted
Add unit test
1 parent a5fb2e6 commit 15f3118

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/app/core/data/bitstream-data.service.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
PutRequest,
3636
} from './request.models';
3737
import { RequestService } from './request.service';
38+
import { RequestParam } from '../cache/models/request-param.model';
3839
import objectContaining = jasmine.objectContaining;
3940

4041
describe('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

Comments
 (0)