File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -869,5 +869,38 @@ describe('formly-form', () => {
869
869
return el ;
870
870
}
871
871
872
+ describe ( `field watchers` , ( ) => {
873
+ it ( 'should throw for a watcher with no listener' , ( ) => {
874
+ scope . fields = [ getNewField ( {
875
+ watcher : { }
876
+ } ) ] ;
872
877
878
+ expect ( compileAndDigest ) . to . throw ( ) ;
879
+ } ) ;
880
+
881
+ it ( `should setup any watchers specified on a field` , ( ) => {
882
+ scope . model = { } ;
883
+
884
+ const listener = sinon . spy ( ) ;
885
+ const expression = sinon . spy ( ) ;
886
+
887
+ scope . fields = [ getNewField ( {
888
+ watcher : {
889
+ listener : ''
890
+ }
891
+ } ) , getNewField ( {
892
+ watcher : [ {
893
+ listener : '' ,
894
+ expression : ''
895
+ } , {
896
+ listener,
897
+ expression
898
+ } ]
899
+ } ) ] ;
900
+
901
+ expect ( compileAndDigest ) . to . not . throw ( ) ;
902
+ expect ( listener ) . to . have . been . called ;
903
+ expect ( expression ) . to . have . been . called ;
904
+ } ) ;
905
+ } ) ;
873
906
} ) ;
You can’t perform that action at this time.
0 commit comments