@@ -55,38 +55,38 @@ import {
5555 DomainDesign ,
5656 DomainField ,
5757 DomainIndex ,
58- IDomainIndex ,
5958 FieldErrors ,
6059 getValidValuesDetailStr ,
6160 getValidValuesFromArray ,
6261 IDomainField ,
62+ IDomainIndex ,
6363 isPropertyTypeAllowed ,
6464 isValidTextChoiceValue ,
6565 PropertyValidator ,
6666 PropertyValidatorProperties ,
6767} from './models' ;
6868import {
6969 BOOLEAN_RANGE_URI ,
70+ CALCULATED_CONCEPT_URI ,
7071 CONCEPT_CODE_CONCEPT_URI ,
72+ DATE_RANGE_URI ,
73+ DATETIME_RANGE_URI ,
74+ DERIVATION_DATA_SCOPES ,
7175 DOMAIN_FIELD_FULLY_LOCKED ,
7276 DOMAIN_FIELD_NOT_LOCKED ,
7377 DOMAIN_FIELD_PARTIALLY_LOCKED ,
78+ DOMAIN_FIELD_PRIMARY_KEY_LOCKED ,
7479 INT_RANGE_URI ,
7580 MULTILINE_RANGE_URI ,
76- PHILEVEL_NOT_PHI ,
7781 PHILEVEL_FULL_PHI ,
7882 PHILEVEL_LIMITED_PHI ,
83+ PHILEVEL_NOT_PHI ,
7984 PHILEVEL_RESTRICTED_PHI ,
8085 SAMPLE_TYPE_CONCEPT_URI ,
8186 STORAGE_UNIQUE_ID_CONCEPT_URI ,
8287 STRING_RANGE_URI ,
8388 TEXT_CHOICE_CONCEPT_URI ,
84- DERIVATION_DATA_SCOPES ,
85- DOMAIN_FIELD_PRIMARY_KEY_LOCKED ,
86- DATETIME_RANGE_URI ,
87- DATE_RANGE_URI ,
8889 TIME_RANGE_URI ,
89- CALCULATED_CONCEPT_URI ,
9090} from './constants' ;
9191
9292beforeAll ( ( ) => {
@@ -1419,3 +1419,54 @@ describe('isValidTextChoiceValue', () => {
14191419 expect ( isValidTextChoiceValue ( ' a ' ) ) . toBeTruthy ( ) ;
14201420 } ) ;
14211421} ) ;
1422+
1423+ describe ( 'resolveBaseProperties' , ( ) => {
1424+ test ( 'infer SampleId' , ( ) => {
1425+ let field = DomainField . resolveBaseProperties ( { name : 'OtherId' } ) ;
1426+ expect ( field . dataType ) . toBe ( TEXT_TYPE ) ;
1427+ expect ( field . conceptURI ) . toBe ( undefined ) ;
1428+ expect ( field . rangeURI ) . toBe ( undefined ) ;
1429+ expect ( field . required ) . toBe ( undefined ) ;
1430+
1431+ field = DomainField . resolveBaseProperties ( {
1432+ propertyId : 1 ,
1433+ name : 'SampleId' ,
1434+ } ) ;
1435+ expect ( field . dataType ) . toBe ( LOOKUP_TYPE ) ;
1436+ expect ( field . conceptURI ) . toBe ( undefined ) ;
1437+ expect ( field . rangeURI ) . toBe ( undefined ) ;
1438+ expect ( field . required ) . toBe ( undefined ) ;
1439+
1440+ field = DomainField . resolveBaseProperties ( { name : 'SampleId' } ) ;
1441+ expect ( field . dataType ) . toBe ( SAMPLE_TYPE ) ;
1442+ expect ( field . conceptURI ) . toBe ( SAMPLE_TYPE . conceptURI ) ;
1443+ expect ( field . rangeURI ) . toBe ( SAMPLE_TYPE . rangeURI ) ;
1444+ expect ( field . required ) . toBe ( true ) ;
1445+
1446+ // GitHub Issue 787
1447+ field = DomainField . resolveBaseProperties ( { name : 'SampleId' , required : false } ) ;
1448+ expect ( field . dataType ) . toBe ( SAMPLE_TYPE ) ;
1449+ expect ( field . conceptURI ) . toBe ( SAMPLE_TYPE . conceptURI ) ;
1450+ expect ( field . rangeURI ) . toBe ( SAMPLE_TYPE . rangeURI ) ;
1451+ expect ( field . required ) . toBe ( undefined ) ;
1452+ } ) ;
1453+
1454+ test ( 'lockType' , ( ) => {
1455+ expect ( DomainField . resolveBaseProperties ( { } ) . lockType ) . toBe ( DOMAIN_FIELD_NOT_LOCKED ) ;
1456+ expect ( DomainField . resolveBaseProperties ( { lockType : DOMAIN_FIELD_PARTIALLY_LOCKED } ) . lockType ) . toBe (
1457+ DOMAIN_FIELD_PARTIALLY_LOCKED
1458+ ) ;
1459+ expect ( DomainField . resolveBaseProperties ( { lockType : DOMAIN_FIELD_FULLY_LOCKED } ) . lockType ) . toBe (
1460+ DOMAIN_FIELD_FULLY_LOCKED
1461+ ) ;
1462+ expect ( DomainField . resolveBaseProperties ( { name : 'test1' } , List ( [ 'test2' ] ) ) . lockType ) . toBe (
1463+ DOMAIN_FIELD_NOT_LOCKED
1464+ ) ;
1465+ expect ( DomainField . resolveBaseProperties ( { name : 'test1' } , List ( [ 'test1' ] ) ) . lockType ) . toBe (
1466+ DOMAIN_FIELD_PARTIALLY_LOCKED
1467+ ) ;
1468+ expect ( DomainField . resolveBaseProperties ( { name : 'TEST1' } , List ( [ 'test1' ] ) ) . lockType ) . toBe (
1469+ DOMAIN_FIELD_PARTIALLY_LOCKED
1470+ ) ;
1471+ } ) ;
1472+ } ) ;
0 commit comments