62589: Added tests for more coverage

This commit is contained in:
Kristof De Langhe
2019-09-30 10:35:52 +02:00
parent 145ed346c8
commit a2fb8a316b
6 changed files with 213 additions and 6 deletions

View File

@@ -67,8 +67,12 @@ describe('CollectionItemMapperComponent', () => {
sort: new SortOptions('dc.title', SortDirection.ASC),
scope: mockCollection.id
}));
const url = 'http://test.url';
const urlWithParam = url + '?param=value';
const routerStub = Object.assign(new RouterStub(), {
url: 'http://test.url'
url: urlWithParam,
navigateByUrl: {},
navigate: {}
});
const searchConfigServiceStub = {
paginatedSearchOptions: mockSearchOptions
@@ -168,4 +172,41 @@ describe('CollectionItemMapperComponent', () => {
});
});
describe('tabChange', () => {
beforeEach(() => {
spyOn(routerStub, 'navigateByUrl');
comp.tabChange({});
});
it('should navigate to the same page to remove parameters', () => {
expect(router.navigateByUrl).toHaveBeenCalledWith(url);
});
});
describe('buildQuery', () => {
const query = 'query';
const expected = `-location.coll:\"${mockCollection.id}\" AND ${query}`;
let result;
beforeEach(() => {
result = comp.buildQuery(mockCollection.id, query);
});
it('should build a solr query to exclude the provided collection', () => {
expect(result).toEqual(expected);
})
});
describe('onCancel', () => {
beforeEach(() => {
spyOn(routerStub, 'navigate');
comp.onCancel();
});
it('should navigate to the collection page', () => {
expect(router.navigate).toHaveBeenCalledWith(['/collections/', mockCollection.id]);
});
});
});