@@ -701,34 +701,52 @@ describe('formly-field', function() {
701
701
) ;
702
702
} ) ;
703
703
704
- describe ( `disabled` , ( ) => {
705
- it ( `should not do anything if the given instance is disabled` , ( ) => {
706
- inputType . apiCheckInstance . config . disabled = true ;
707
- scope . fields = [
708
- { type, templateOptions : { label : 'string' } }
709
- ] ;
710
- shouldNotWarn ( compileAndDigest ) ;
711
- } ) ;
704
+ describe ( `apiCheckInstance` , ( ) => {
705
+ describe ( `disabled` , ( ) => {
706
+ it ( `should not do anything if the given instance is disabled` , ( ) => {
707
+ inputType . apiCheckInstance . config . disabled = true ;
708
+ scope . fields = [
709
+ { type, templateOptions : { label : 'string' } }
710
+ ] ;
711
+ shouldNotWarn ( compileAndDigest ) ;
712
+ } ) ;
712
713
713
- it ( `should not do anything if no instance is provided and the formly instance is disabled` , inject ( ( formlyApiCheck ) => {
714
- formlyApiCheck . config . disabled = true ;
715
- formlyConfig . setType ( {
716
- name : 'someOtherType' ,
717
- template : '<hr />' ,
718
- apiCheck : checker => ( { data : { foo : checker . bool } } )
714
+ it ( `should not do anything if no instance is provided and the formly instance is disabled` , inject ( ( formlyApiCheck ) => {
715
+ formlyApiCheck . config . disabled = true ;
716
+ formlyConfig . setType ( {
717
+ name : 'someOtherType' ,
718
+ template : '<hr />' ,
719
+ apiCheck : checker => ( { data : { foo : checker . bool } } )
720
+ } ) ;
721
+ scope . fields = [ { type : 'someOtherType' } ] ;
722
+ shouldNotWarn ( compileAndDigest ) ;
723
+ formlyApiCheck . config . disabled = false ;
724
+ } ) ) ;
725
+
726
+ it ( `should not do anything if the global instance is disabled` , ( ) => {
727
+ apiCheck . globalConfig . disabled = true ;
728
+ scope . fields = [
729
+ { type, templateOptions : { label : 'string' } }
730
+ ] ;
731
+ shouldNotWarn ( compileAndDigest ) ;
732
+ apiCheck . globalConfig . disabled = false ;
719
733
} ) ;
720
- scope . fields = [ { type : 'someOtherType' } ] ;
721
- shouldNotWarn ( compileAndDigest ) ;
722
- formlyApiCheck . config . disabled = false ;
723
- } ) ) ;
734
+ } ) ;
724
735
725
- it ( `should not do anything if the global instance is disabled` , ( ) => {
726
- apiCheck . globalConfig . disabled = true ;
727
- scope . fields = [
728
- { type, templateOptions : { label : 'string' } }
729
- ] ;
730
- shouldNotWarn ( compileAndDigest ) ;
731
- apiCheck . globalConfig . disabled = false ;
736
+ describe . skip ( `formlyConfig.extras.apiCheckInstance` , ( ) => {
737
+ it ( `should default to this instance when specified and no specific type instance is specified` , ( ) => {
738
+ const globalApiCheckInstance = apiCheck ( {
739
+ output : { prefix : 'custom-api-check' }
740
+ } ) ;
741
+ const warnSpy = sinon . spy ( globalApiCheckInstance , 'warn' ) ;
742
+ formlyConfig . extras . apiCheckInstance = globalApiCheckInstance ;
743
+ delete inputType . apiCheckInstance ;
744
+ scope . fields = [
745
+ { type, templateOptions : { label : 'string' , className : 'valid' } }
746
+ ] ;
747
+ compileAndDigest ( ) ;
748
+ expect ( warnSpy ) . to . have . been . calledOnce ;
749
+ } ) ;
732
750
} ) ;
733
751
} ) ;
734
752
0 commit comments