Skip to content

Commit 19db3fa

Browse files
msarmietdonohue
authored andcommitted
Add unit test
1 parent 2a5d779 commit 19db3fa

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
@@ -16,6 +16,7 @@ import { NotificationsService } from '../../shared/notifications/notifications.s
1616
import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub';
1717
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
1818
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
19+
import { RequestParam } from '../cache/models/request-param.model';
1920
import { ObjectCacheService } from '../cache/object-cache.service';
2021
import { Bitstream } from '../shared/bitstream.model';
2122
import { 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

Comments
 (0)