59415: Fixed existing tests

This commit is contained in:
Kristof De Langhe
2019-01-30 11:32:12 +01:00
parent da7723c27b
commit 18afb35e74
3 changed files with 11 additions and 25 deletions

View File

@@ -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 * 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 * - metadataDefinition: The metadata definition to fetch entries or items for
* - pagination: The pagination options to use * - pagination: Optional pagination options to use
* - sort: The sorting options to use * - sort: Optional sorting options to use
* - scope: An optional scope to limit the results within a specific collection or community * - scope: An optional scope to limit the results within a specific collection or community
*/ */
export class BrowseEntrySearchOptions { export class BrowseEntrySearchOptions {
constructor(public metadataDefinition: string, constructor(public metadataDefinition: string,
public pagination: PaginationComponentOptions, public pagination?: PaginationComponentOptions,
public sort: SortOptions, public sort?: SortOptions,
public scope?: string) { public scope?: string) {
} }
} }

View File

@@ -10,6 +10,7 @@ import { BrowseEndpointRequest, BrowseEntriesRequest, BrowseItemsRequest } from
import { RequestService } from '../data/request.service'; import { RequestService } from '../data/request.service';
import { BrowseDefinition } from '../shared/browse-definition.model'; import { BrowseDefinition } from '../shared/browse-definition.model';
import { BrowseService } from './browse.service'; import { BrowseService } from './browse.service';
import { BrowseEntrySearchOptions } from './browse-entry-search-options.model';
describe('BrowseService', () => { describe('BrowseService', () => {
let scheduler: TestScheduler; let scheduler: TestScheduler;
@@ -162,14 +163,14 @@ describe('BrowseService', () => {
it('should configure a new BrowseEntriesRequest', () => { it('should configure a new BrowseEntriesRequest', () => {
const expected = new BrowseEntriesRequest(requestService.generateRequestId(), browseDefinitions[1]._links.entries); 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(); scheduler.flush();
expect(requestService.configure).toHaveBeenCalledWith(expected); expect(requestService.configure).toHaveBeenCalledWith(expected);
}); });
it('should call RemoteDataBuildService to create the RemoteData Observable', () => { 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(); expect(rdbService.toRemoteDataObservable).toHaveBeenCalled();
@@ -181,14 +182,14 @@ describe('BrowseService', () => {
it('should configure a new BrowseItemsRequest', () => { it('should configure a new BrowseItemsRequest', () => {
const expected = new BrowseItemsRequest(requestService.generateRequestId(), browseDefinitions[1]._links.items + '?filterValue=' + mockAuthorName); 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(); scheduler.flush();
expect(requestService.configure).toHaveBeenCalledWith(expected); expect(requestService.configure).toHaveBeenCalledWith(expected);
}); });
it('should call RemoteDataBuildService to create the RemoteData Observable', () => { 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(); expect(rdbService.toRemoteDataObservable).toHaveBeenCalled();
@@ -202,7 +203,7 @@ describe('BrowseService', () => {
const definitionID = 'invalidID'; const definitionID = 'invalidID';
const expected = cold('--#-', undefined, new Error(`No metadata browse definition could be found for id '${definitionID}'`)) 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 definitionID = 'invalidID';
const expected = cold('--#-', undefined, new Error(`No metadata browse definition could be found for id '${definitionID}'`)) 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);
}); });
}); });
}); });

View File

@@ -105,21 +105,6 @@ describe('BrowseEntriesResponseParsingService', () => {
} as DSpaceRESTV2Response; } as DSpaceRESTV2Response;
const invalidResponseNotAList = { 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' statusCode: '200'
} as DSpaceRESTV2Response; } as DSpaceRESTV2Response;