Skip to content
Snippets Groups Projects
Commit 18afb35e authored by Kristof De Langhe's avatar Kristof De Langhe
Browse files

59415: Fixed existing tests

parent da7723c2
Branches
Tags
No related merge requests found
......@@ -4,14 +4,14 @@ import { SortOptions } from '../cache/models/sort-options.model';
/**
* A class that defines the search options to be used for fetching browse entries or items
* - metadataDefinition: The metadata definition to fetch entries or items for
* - pagination: The pagination options to use
* - sort: The sorting options to use
* - pagination: Optional pagination options to use
* - sort: Optional sorting options to use
* - scope: An optional scope to limit the results within a specific collection or community
*/
export class BrowseEntrySearchOptions {
constructor(public metadataDefinition: string,
public pagination: PaginationComponentOptions,
public sort: SortOptions,
public pagination?: PaginationComponentOptions,
public sort?: SortOptions,
public scope?: string) {
}
}
......@@ -10,6 +10,7 @@ import { BrowseEndpointRequest, BrowseEntriesRequest, BrowseItemsRequest } from
import { RequestService } from '../data/request.service';
import { BrowseDefinition } from '../shared/browse-definition.model';
import { BrowseService } from './browse.service';
import { BrowseEntrySearchOptions } from './browse-entry-search-options.model';
describe('BrowseService', () => {
let scheduler: TestScheduler;
......@@ -162,14 +163,14 @@ describe('BrowseService', () => {
it('should configure a new BrowseEntriesRequest', () => {
const expected = new BrowseEntriesRequest(requestService.generateRequestId(), browseDefinitions[1]._links.entries);
scheduler.schedule(() => service.getBrowseEntriesFor(browseDefinitions[1].id).subscribe());
scheduler.schedule(() => service.getBrowseEntriesFor(new BrowseEntrySearchOptions(browseDefinitions[1].id)).subscribe());
scheduler.flush();
expect(requestService.configure).toHaveBeenCalledWith(expected);
});
it('should call RemoteDataBuildService to create the RemoteData Observable', () => {
service.getBrowseEntriesFor(browseDefinitions[1].id);
service.getBrowseEntriesFor(new BrowseEntrySearchOptions(browseDefinitions[1].id));
expect(rdbService.toRemoteDataObservable).toHaveBeenCalled();
......@@ -181,14 +182,14 @@ describe('BrowseService', () => {
it('should configure a new BrowseItemsRequest', () => {
const expected = new BrowseItemsRequest(requestService.generateRequestId(), browseDefinitions[1]._links.items + '?filterValue=' + mockAuthorName);
scheduler.schedule(() => service.getBrowseItemsFor(browseDefinitions[1].id, mockAuthorName).subscribe());
scheduler.schedule(() => service.getBrowseItemsFor(mockAuthorName, new BrowseEntrySearchOptions(browseDefinitions[1].id)).subscribe());
scheduler.flush();
expect(requestService.configure).toHaveBeenCalledWith(expected);
});
it('should call RemoteDataBuildService to create the RemoteData Observable', () => {
service.getBrowseItemsFor(browseDefinitions[1].id, mockAuthorName);
service.getBrowseItemsFor(mockAuthorName, new BrowseEntrySearchOptions(browseDefinitions[1].id));
expect(rdbService.toRemoteDataObservable).toHaveBeenCalled();
......@@ -202,7 +203,7 @@ describe('BrowseService', () => {
const definitionID = 'invalidID';
const expected = cold('--#-', undefined, new Error(`No metadata browse definition could be found for id '${definitionID}'`))
expect(service.getBrowseEntriesFor(definitionID)).toBeObservable(expected);
expect(service.getBrowseEntriesFor(new BrowseEntrySearchOptions(definitionID))).toBeObservable(expected);
});
});
......@@ -212,7 +213,7 @@ describe('BrowseService', () => {
const definitionID = 'invalidID';
const expected = cold('--#-', undefined, new Error(`No metadata browse definition could be found for id '${definitionID}'`))
expect(service.getBrowseItemsFor(definitionID, mockAuthorName)).toBeObservable(expected);
expect(service.getBrowseItemsFor(mockAuthorName, new BrowseEntrySearchOptions(definitionID))).toBeObservable(expected);
});
});
});
......
......@@ -105,21 +105,6 @@ describe('BrowseEntriesResponseParsingService', () => {
} as DSpaceRESTV2Response;
const invalidResponseNotAList = {
payload: {
authority: null,
value: 'Arulmozhiyal, Ramaswamy',
valueLang: null,
count: 1,
type: 'browseEntry',
_links: {
self: {
href: 'https://rest.api/discover/browses/author/entries'
},
items: {
href: 'https://rest.api/discover/browses/author/items?filterValue=Arulmozhiyal, Ramaswamy'
}
},
},
statusCode: '200'
} as DSpaceRESTV2Response;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment