fix AoT issues

This commit is contained in:
Art Lowel
2020-02-18 18:52:33 +01:00
parent bc00c000a6
commit 6824ccb307
6 changed files with 80 additions and 43 deletions

View File

@@ -164,7 +164,7 @@ export const getLinkDefinition = <T extends HALResource>(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<string, LinkDefinition<any>> = linkMap.get(parent) || new Map();
const childMap: Map<string, LinkDefinition<any>> = linkMap.get(child) || new Map();
@@ -177,4 +177,4 @@ export const inheritLinkAnnotations = (parent: any): any => {
linkMap.set(child, childMap);
}
};
}

View File

@@ -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');
});
});

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -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({

View File

@@ -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: ''
}
}
}
];