@@ -9,12 +9,9 @@ import {
99} from '@angular/forms' ;
1010import {
1111 DISABLED_MATCHER_PROVIDER ,
12- DynamicFormControlRelation ,
1312 DynamicFormRelationService ,
1413 HIDDEN_MATCHER ,
1514 HIDDEN_MATCHER_PROVIDER ,
16- MATCH_VISIBLE ,
17- OR_OPERATOR ,
1815 REQUIRED_MATCHER_PROVIDER ,
1916} from '@ng-dynamic-forms/core' ;
2017
@@ -26,6 +23,7 @@ import {
2623import { FormBuilderService } from '../form-builder.service' ;
2724import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model' ;
2825import { DsDynamicTypeBindRelationService } from './ds-dynamic-type-bind-relation.service' ;
26+ import { getTypeBindRelations } from './type-bind.utils' ;
2927
3028describe ( 'DSDynamicTypeBindRelationService test suite' , ( ) => {
3129 let service : DsDynamicTypeBindRelationService ;
@@ -85,7 +83,7 @@ describe('DSDynamicTypeBindRelationService test suite', () => {
8583 } ) ;
8684 it ( 'Should get 1 related form models for mock relation model data' , ( ) => {
8785 const testModel = mockInputWithTypeBindModel ;
88- testModel . typeBindRelations = getTypeBindRelations ( [ 'boundType' ] ) ;
86+ testModel . typeBindRelations = getTypeBindRelations ( [ 'boundType' ] , 'dc.type' ) ;
8987 const relatedModels = service . getRelatedFormModel ( testModel ) ;
9088 expect ( relatedModels ) . toHaveSize ( 1 ) ;
9189 } ) ;
@@ -94,7 +92,7 @@ describe('DSDynamicTypeBindRelationService test suite', () => {
9492 describe ( 'Test matchesCondition method' , ( ) => {
9593 it ( 'Should receive one subscription to dc.type type binding"' , ( ) => {
9694 const testModel = mockInputWithTypeBindModel ;
97- testModel . typeBindRelations = getTypeBindRelations ( [ 'boundType' ] ) ;
95+ testModel . typeBindRelations = getTypeBindRelations ( [ 'boundType' ] , 'dc.type' ) ;
9896 const dcTypeControl = new UntypedFormControl ( ) ;
9997 dcTypeControl . setValue ( 'boundType' ) ;
10098 let subscriptions = service . subscribeRelations ( testModel , dcTypeControl ) ;
@@ -103,7 +101,7 @@ describe('DSDynamicTypeBindRelationService test suite', () => {
103101
104102 it ( 'Expect hasMatch to be true (ie. this should be hidden)' , ( ) => {
105103 const testModel = mockInputWithTypeBindModel ;
106- testModel . typeBindRelations = getTypeBindRelations ( [ 'boundType' ] ) ;
104+ testModel . typeBindRelations = getTypeBindRelations ( [ 'boundType' ] , 'dc.type' ) ;
107105 const dcTypeControl = new UntypedFormControl ( ) ;
108106 dcTypeControl . setValue ( 'boundType' ) ;
109107 testModel . typeBindRelations [ 0 ] . when [ 0 ] . value = 'anotherType' ;
@@ -118,7 +116,7 @@ describe('DSDynamicTypeBindRelationService test suite', () => {
118116
119117 it ( 'Expect hasMatch to be false (ie. this should NOT be hidden)' , ( ) => {
120118 const testModel = mockInputWithTypeBindModel ;
121- testModel . typeBindRelations = getTypeBindRelations ( [ 'boundType' ] ) ;
119+ testModel . typeBindRelations = getTypeBindRelations ( [ 'boundType' ] , 'dc.type' ) ;
122120 const dcTypeControl = new UntypedFormControl ( ) ;
123121 dcTypeControl . setValue ( 'boundType' ) ;
124122 testModel . typeBindRelations [ 0 ] . when [ 0 ] . value = 'boundType' ;
@@ -134,18 +132,3 @@ describe('DSDynamicTypeBindRelationService test suite', () => {
134132 } ) ;
135133
136134} ) ;
137-
138- function getTypeBindRelations ( configuredTypeBindValues : string [ ] ) : DynamicFormControlRelation [ ] {
139- const bindValues = [ ] ;
140- configuredTypeBindValues . forEach ( ( value ) => {
141- bindValues . push ( {
142- id : 'dc.type' ,
143- value : value ,
144- } ) ;
145- } ) ;
146- return [ {
147- match : MATCH_VISIBLE ,
148- operator : OR_OPERATOR ,
149- when : bindValues ,
150- } ] ;
151- }
0 commit comments