Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
msarmie authored and tdonohue committed Jan 22, 2025
1 parent a5fb2e6 commit 15f3118
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/app/core/data/bitstream-data.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
PutRequest,
} from './request.models';
import { RequestService } from './request.service';
import { RequestParam } from '../cache/models/request-param.model';
import objectContaining = jasmine.objectContaining;

describe('BitstreamDataService', () => {
Expand Down Expand Up @@ -176,4 +177,30 @@ describe('BitstreamDataService', () => {
expect(service.invalidateByHref).toHaveBeenCalledWith('fake-bitstream2-self');
});
});

describe('findByItemHandle', () => {
it('should encode the filename correctly in the search parameters', () => {
const handle = '123456789/1234';
const sequenceId = '5';
const filename = 'file with spaces.pdf';
const searchParams = [
new RequestParam('handle', handle),
new RequestParam('sequenceId', sequenceId),
new RequestParam('filename', filename)

Check failure on line 189 in src/app/core/data/bitstream-data.service.spec.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Missing trailing comma

Check failure on line 189 in src/app/core/data/bitstream-data.service.spec.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

Missing trailing comma
];
const linksToFollow: FollowLinkConfig<Bitstream>[] = [];

spyOn(service as any, 'getSearchByHref').and.callThrough();

service.getSearchByHref('byItemHandle', { searchParams }, ...linksToFollow).subscribe((href) => {
expect(service.getSearchByHref).toHaveBeenCalledWith(
'byItemHandle',
{ searchParams },
...linksToFollow

Check failure on line 199 in src/app/core/data/bitstream-data.service.spec.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Missing trailing comma

Check failure on line 199 in src/app/core/data/bitstream-data.service.spec.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

Missing trailing comma
);

expect(href).toBe(`${url}/bitstreams/search/byItemHandle?handle=123456789%2F1234&sequenceId=5&filename=file%20with%20spaces.pdf`);
});
});
});
});

0 comments on commit 15f3118

Please sign in to comment.