@@ -31,10 +31,12 @@ class TestModel implements HALResource {
3131 self : HALLink ;
3232 predecessor : HALLink ;
3333 successor : HALLink ;
34+ standardLinkName : HALLink ;
3435 } ;
3536
3637 predecessor ?: TestModel ;
3738 successor ?: TestModel ;
39+ renamedProperty ?: TestModel ;
3840}
3941
4042const mockDataServiceMap : any = new Map ( [
@@ -66,6 +68,24 @@ describe('LinkService', () => {
6668 testDataService = new TestDataService ( ) ;
6769 spyOn ( testDataService , 'findListByHref' ) . and . callThrough ( ) ;
6870 spyOn ( testDataService , 'findByHref' ) . and . callThrough ( ) ;
71+
72+ const linksDefinitions = new Map ( ) ;
73+ linksDefinitions . set ( 'predecessor' , {
74+ resourceType : TEST_MODEL ,
75+ linkName : 'predecessor' ,
76+ propertyName : 'predecessor' ,
77+ } ) ;
78+ linksDefinitions . set ( 'successor' , {
79+ resourceType : TEST_MODEL ,
80+ linkName : 'successor' ,
81+ propertyName : 'successor' ,
82+ } ) ;
83+ linksDefinitions . set ( 'standardLinkName' , {
84+ resourceType : TEST_MODEL ,
85+ linkName : 'standardLinkName' ,
86+ propertyName : 'renamedProperty' ,
87+ } ) ;
88+
6989 TestBed . configureTestingModule ( {
7090 providers : [
7191 LinkService ,
@@ -87,18 +107,7 @@ describe('LinkService', () => {
87107 } ,
88108 {
89109 provide : LINK_DEFINITION_MAP_FACTORY ,
90- useValue : jasmine . createSpy ( 'getLinkDefinitions' ) . and . returnValue ( [
91- {
92- resourceType : TEST_MODEL ,
93- linkName : 'predecessor' ,
94- propertyName : 'predecessor' ,
95- } ,
96- {
97- resourceType : TEST_MODEL ,
98- linkName : 'successor' ,
99- propertyName : 'successor' ,
100- } ,
101- ] ) ,
110+ useValue : jasmine . createSpy ( 'getLinkDefinitions' ) . and . returnValue ( linksDefinitions ) ,
102111 } ,
103112 ] ,
104113 } ) ;
@@ -117,6 +126,15 @@ describe('LinkService', () => {
117126 } ) ;
118127 } ) ;
119128 } ) ;
129+ describe ( `when the propertyName is different than linkName` , ( ) => {
130+ beforeEach ( ( ) => {
131+ result = service . resolveLink ( testModel , followLink ( 'standardLinkName' , { } ) ) ;
132+ } ) ;
133+ it ( 'link should be assign to custom property' , ( ) => {
134+ expect ( result . renamedProperty ) . toBeDefined ( ) ;
135+ expect ( result . standardLinkName ) . toBeUndefined ( ) ;
136+ } ) ;
137+ } ) ;
120138 describe ( `when the linkdefinition concerns a list` , ( ) => {
121139 beforeEach ( ( ) => {
122140 ( ( service as any ) . getLinkDefinition as jasmine . Spy ) . and . returnValue ( {
0 commit comments