@@ -11,15 +11,14 @@ import {
11
11
REQUIRED_MATCHER_PROVIDER ,
12
12
} from '@ng-dynamic-forms/core' ;
13
13
14
- import {
15
- mockInputWithTypeBindModel , MockRelationModel
16
- } from '../../../mocks/form-models.mock' ;
14
+ import { mockInputWithTypeBindModel , MockRelationModel } from '../../../mocks/form-models.mock' ;
17
15
import { DsDynamicTypeBindRelationService } from './ds-dynamic-type-bind-relation.service' ;
18
16
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model' ;
19
- import { UntypedFormControl , ReactiveFormsModule } from '@angular/forms' ;
17
+ import { ReactiveFormsModule , UntypedFormControl } from '@angular/forms' ;
20
18
import { FormBuilderService } from '../form-builder.service' ;
21
19
import { getMockFormBuilderService } from '../../../mocks/form-builder-service.mock' ;
22
20
import { Injector } from '@angular/core' ;
21
+ import { VocabularyEntryDetail } from '../../../../core/submission/vocabularies/models/vocabulary-entry-detail.model' ;
23
22
24
23
describe ( 'DSDynamicTypeBindRelationService test suite' , ( ) => {
25
24
let service : DsDynamicTypeBindRelationService ;
@@ -40,19 +39,19 @@ describe('DSDynamicTypeBindRelationService test suite', () => {
40
39
41
40
beforeEach ( inject ( [ DsDynamicTypeBindRelationService , DynamicFormRelationService ] ,
42
41
( relationService : DsDynamicTypeBindRelationService ,
43
- formRelationService : DynamicFormRelationService ,
42
+ formRelationService : DynamicFormRelationService
44
43
) => {
45
- service = relationService ;
46
- dynamicFormRelationService = formRelationService ;
47
- } ) ) ;
44
+ service = relationService ;
45
+ dynamicFormRelationService = formRelationService ;
46
+ } ) ) ;
48
47
49
48
describe ( 'Test getTypeBindValue method' , ( ) => {
50
49
it ( 'Should get type bind "boundType" from the given metadata object value' , ( ) => {
51
- const mockMetadataValueObject : FormFieldMetadataValueObject = new FormFieldMetadataValueObject (
52
- 'boundType' , null , null , null , 'Bound Type'
53
- ) ;
54
- const bindType = service . getTypeBindValue ( mockMetadataValueObject ) ;
55
- expect ( bindType ) . toBe ( 'boundType' ) ;
50
+ const mockMetadataValueObject : FormFieldMetadataValueObject = new FormFieldMetadataValueObject (
51
+ 'boundType' , null , null , null , 'Bound Type'
52
+ ) ;
53
+ const bindType = service . getTypeBindValue ( mockMetadataValueObject ) ;
54
+ expect ( bindType ) . toBe ( 'boundType' ) ;
56
55
} ) ;
57
56
it ( 'Should get type authority key "bound-auth-key" from the given metadata object value' , ( ) => {
58
57
const mockMetadataValueObject : FormFieldMetadataValueObject = new FormFieldMetadataValueObject (
@@ -61,6 +60,19 @@ describe('DSDynamicTypeBindRelationService test suite', () => {
61
60
const bindType = service . getTypeBindValue ( mockMetadataValueObject ) ;
62
61
expect ( bindType ) . toBe ( 'bound-auth-key' ) ;
63
62
} ) ;
63
+ it ( 'Should get type bind "boundType" from the given vocabulary entry object value' , ( ) => {
64
+ const vocabularyEntry = new VocabularyEntryDetail ( ) ;
65
+ vocabularyEntry . value = vocabularyEntry . display = 'boundType' ;
66
+ const bindType = service . getTypeBindValue ( vocabularyEntry ) ;
67
+ expect ( bindType ) . toBe ( 'boundType' ) ;
68
+ } ) ;
69
+ it ( 'Should get type authority key "bound-auth-key" from the given vocabulary entry object value' , ( ) => {
70
+ const vocabularyEntry = new VocabularyEntryDetail ( ) ;
71
+ vocabularyEntry . id = vocabularyEntry . authority = 'bound-auth-key' ;
72
+ vocabularyEntry . value = vocabularyEntry . display = 'boundType' ;
73
+ const bindType = service . getTypeBindValue ( vocabularyEntry ) ;
74
+ expect ( bindType ) . toBe ( 'bound-auth-key' ) ;
75
+ } ) ;
64
76
it ( 'Should get passed string returned directly as string passed instead of metadata' , ( ) => {
65
77
const bindType = service . getTypeBindValue ( 'rawString' ) ;
66
78
expect ( bindType ) . toBe ( 'rawString' ) ;
0 commit comments