diff --git a/src/app/core/cache/builders/build-decorators.ts b/src/app/core/cache/builders/build-decorators.ts index a1119e5fec..50a70e051f 100644 --- a/src/app/core/cache/builders/build-decorators.ts +++ b/src/app/core/cache/builders/build-decorators.ts @@ -164,7 +164,7 @@ export const getLinkDefinition = (source: GenericConstruc * * @param parent the parent class to inherit @link annotations from */ -export const inheritLinkAnnotations = (parent: any): any => { +export function inheritLinkAnnotations(parent: any): any { return (child: any) => { const parentMap: Map> = linkMap.get(parent) || new Map(); const childMap: Map> = linkMap.get(child) || new Map(); @@ -177,4 +177,4 @@ export const inheritLinkAnnotations = (parent: any): any => { linkMap.set(child, childMap); } -}; +} diff --git a/src/app/core/cache/builders/link.service.spec.ts b/src/app/core/cache/builders/link.service.spec.ts index 21af7dda7c..b34aea320a 100644 --- a/src/app/core/cache/builders/link.service.spec.ts +++ b/src/app/core/cache/builders/link.service.spec.ts @@ -123,7 +123,7 @@ describe('LinkService', () => { }); it('should call getLinkDefinition with the correct model and link', () => { - expect(decorators.getLinkDefinition).toHaveBeenCalledWith(testModel.constructor, 'predecessor'); + expect(decorators.getLinkDefinition).toHaveBeenCalledWith(testModel.constructor as any, 'predecessor'); }); it('should call getDataServiceFor with the correct resource type', () => { @@ -186,8 +186,8 @@ describe('LinkService', () => { describe('removeResolvedLinks', () => { beforeEach(() => { - testModel.predecessor = 'predecessor value'; - testModel.successor = 'successor value'; + testModel.predecessor = 'predecessor value' as any; + testModel.successor = 'successor value' as any; spyOnFunction(decorators, 'getLinkDefinitions').and.returnValue([ { resourceType: TEST_MODEL, @@ -213,8 +213,8 @@ describe('LinkService', () => { it('should leave the original object untouched', () => { service.removeResolvedLinks(testModel); - expect(testModel.predecessor).toBe('predecessor value'); - expect(testModel.successor).toBe('successor value'); + expect(testModel.predecessor as any).toBe('predecessor value'); + expect(testModel.successor as any).toBe('successor value'); }); }); diff --git a/src/app/core/cache/object-cache.service.spec.ts b/src/app/core/cache/object-cache.service.spec.ts index c3b7781d70..e7c208e095 100644 --- a/src/app/core/cache/object-cache.service.spec.ts +++ b/src/app/core/cache/object-cache.service.spec.ts @@ -91,7 +91,7 @@ describe('ObjectCacheService', () => { // due to the implementation of spyOn above, this subscribe will be synchronous service.getObjectBySelfLink(selfLink).pipe(first()).subscribe((o) => { - expect(o.self).toBe(selfLink); + expect(o._links.self.href).toBe(selfLink); // this only works if testObj is an instance of TestClass expect(o instanceof Item).toBeTruthy(); } diff --git a/src/app/core/data/relationship.service.spec.ts b/src/app/core/data/relationship.service.spec.ts index f5d370dc0b..247dce1619 100644 --- a/src/app/core/data/relationship.service.spec.ts +++ b/src/app/core/data/relationship.service.spec.ts @@ -33,30 +33,9 @@ describe('RelationshipService', () => { rightwardType: 'isPublicationOfAuthor' }); - const item = Object.assign(new Item(), { - id: 'publication', - uuid: 'publication', - relationships: observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(new PageInfo(), relationships))), - _links: { - relationships: { href: restEndpointURL + '/publication/relationships' }, - self: { href: restEndpointURL + '/publication' } - } - }); - - const relatedItem1 = Object.assign(new Item(), { - id: 'author1', - uuid: 'author1', - _links: { - self: { href: restEndpointURL + '/author1' } - } - }); - const relatedItem2 = Object.assign(new Item(), { - id: 'author2', - uuid: 'author2', - _links: { - self: { href: restEndpointURL + '/author2' } - } - }); + const ri1SelfLink = restEndpointURL + '/author1'; + const ri2SelfLink = restEndpointURL + '/author2'; + const itemSelfLink = restEndpointURL + '/publication'; const relationship1 = Object.assign(new Relationship(), { _links: { @@ -64,10 +43,10 @@ describe('RelationshipService', () => { href: relationshipsEndpointURL + '/2' }, leftItem: { - href: relatedItem1._links.self.href + href: ri1SelfLink }, rightItem: { - href: item._links.self.href + href: itemSelfLink } }, id: '2', @@ -80,18 +59,41 @@ describe('RelationshipService', () => { href: relationshipsEndpointURL + '/3' }, leftItem: { - href: relatedItem2._links.self.href + href: ri2SelfLink }, rightItem: { - href: item._links.self.href - }, + href: itemSelfLink + }, }, id: '3', uuid: '3', relationshipType: observableOf(new RemoteData(false, false, true, undefined, relationshipType)) }); - const relationships = [relationship1, relationship2]; + const relationships = [relationship1, relationship2]; const item = Object.assign(new Item(), { + id: 'publication', + uuid: 'publication', + relationships: observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(new PageInfo(), relationships))), + _links: { + relationships: { href: restEndpointURL + '/publication/relationships' }, + self: { href: itemSelfLink } + } + }); + + const relatedItem1 = Object.assign(new Item(), { + id: 'author1', + uuid: 'author1', + _links: { + self: { href: ri1SelfLink } + } + }); + const relatedItem2 = Object.assign(new Item(), { + id: 'author2', + uuid: 'author2', + _links: { + self: { href: ri2SelfLink } + } + }); relationship1.leftItem = getRemotedataObservable(relatedItem1); relationship1.rightItem = getRemotedataObservable(item); diff --git a/src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-range-option/search-facet-range-option.component.spec.ts b/src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-range-option/search-facet-range-option.component.spec.ts index e6878dadd1..34fb64040c 100644 --- a/src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-range-option/search-facet-range-option.component.spec.ts +++ b/src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-range-option/search-facet-range-option.component.spec.ts @@ -38,7 +38,14 @@ describe('SearchFacetRangeOptionComponent', () => { label: value2, value: value2, count: 20, - search: '' + _links: { + self: { + href: '' + }, + search: { + href: '' + } + } }; const searchLink = '/search'; @@ -96,7 +103,14 @@ describe('SearchFacetRangeOptionComponent', () => { label: '50-60', value: '50-60', count: 20, - search: '' + _links: { + self: { + href: '' + }, + search: { + href: '' + } + } }; (comp as any).updateChangeParams(); expect(comp.changeQueryParams).toEqual({ diff --git a/src/app/shared/search/search-filters/search-filter/search-facet-filter/search-facet-filter.component.spec.ts b/src/app/shared/search/search-filters/search-filter/search-facet-filter/search-facet-filter.component.spec.ts index 1b66e29246..7695497750 100644 --- a/src/app/shared/search/search-filters/search-filter/search-facet-filter/search-facet-filter.component.spec.ts +++ b/src/app/shared/search/search-filters/search-filter/search-facet-filter/search-facet-filter.component.spec.ts @@ -39,17 +39,38 @@ describe('SearchFacetFilterComponent', () => { label: value1, value: value1, count: 52, - search: '' + _links: { + self: { + href: '' + }, + search: { + href: '' + } + } }, { label: value2, value: value2, count: 20, - search: '' + _links: { + self: { + href: '' + }, + search: { + href: '' + } + } }, { label: value3, value: value3, count: 5, - search: '' + _links: { + self: { + href: '' + }, + search: { + href: '' + } + } } ];