@@ -60,7 +60,8 @@ describe('Validations', () => {
60
60
{ name : 'period4' , label : 'period4' , inputType : InputType . DROPDOWNRANGE } ,
61
61
{ name : 'beginningDate' , label : 'beginningDate' , inputType : 'date' } ,
62
62
{ name : 'endDate' , label : 'endDate' , inputType : 'date' } ,
63
- { name : 'shortInput' , label : 'shortInput' , inputType : 'input' , maxCharacters : 10 }
63
+ { name : 'shortInput' , label : 'shortInput' , inputType : 'input' , maxCharacters : 10 } ,
64
+ { name : 'isBelow' , label : 'isBelow' , inputType : 'relation' }
64
65
]
65
66
66
67
} ] } , [ ] ] ,
@@ -119,7 +120,7 @@ describe('Validations', () => {
119
120
120
121
it ( 'validate defined fields' , ( ) => {
121
122
122
- const datastore = jasmine . createSpyObj ( 'datastore' , [ 'find' ] ) ;
123
+ const datastore = jasmine . createSpyObj ( 'datastore' , [ 'find' ] ) ;
123
124
datastore . find . and . returnValues ( Promise . resolve ( { totalCount : 0 , documents : [ ] } ) ) ;
124
125
125
126
const doc = {
@@ -157,6 +158,26 @@ describe('Validations', () => {
157
158
} ) ;
158
159
159
160
161
+ it ( 'validate defined fields - do not allow non-relation fields with the same name as relation fields' , ( ) => {
162
+
163
+ const datastore = jasmine . createSpyObj ( 'datastore' , [ 'find' ] ) ;
164
+ datastore . find . and . returnValues ( Promise . resolve ( { totalCount : 0 , documents : [ ] } ) ) ;
165
+
166
+ const doc = {
167
+ resource : {
168
+ id : '1' ,
169
+ category : 'T' ,
170
+ mandatory : 'm' ,
171
+ isBelow : 'test' ,
172
+ relations : { isBelow : [ '0' ] } ,
173
+ }
174
+ } ;
175
+
176
+ const undefinedFields = Validations . validateDefinedFields ( doc . resource as any , projectConfiguration ) ;
177
+ expect ( undefinedFields ) . toContain ( 'isBelow' ) ;
178
+ } ) ;
179
+
180
+
160
181
it ( 'should report nothing when omitting optional property' , ( ) => {
161
182
162
183
const datastore = jasmine . createSpyObj ( 'datastore' , [ 'find' ] ) ;
0 commit comments