File tree 1 file changed +41
-0
lines changed
1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -48,4 +48,45 @@ describe('directive',function() {
48
48
49
49
} ) ;
50
50
} ) ;
51
+
52
+ it ( 'should display error messages when schemaFormValidate is broadcasted' , function ( ) {
53
+ var exampleSchema = {
54
+ "type" : "object" ,
55
+ "properties" : {
56
+ "name" : {
57
+ "type" : [ "null" , "string" ]
58
+ }
59
+ }
60
+ } ;
61
+
62
+ inject ( function ( $compile , $rootScope ) {
63
+ var scope = $rootScope . $new ( ) ;
64
+
65
+ scope . model = { } ;
66
+ scope . schema = exampleSchema ;
67
+ scope . form = [ {
68
+ key : 'name' ,
69
+ $validators : {
70
+ custom : function ( value ) {
71
+ return ! ! value ;
72
+ }
73
+ } ,
74
+ validationMessage : {
75
+ custom : 'This is required!'
76
+ }
77
+ } ] ;
78
+
79
+ scope . validateForm = function ( ) {
80
+ scope . $broadcast ( 'schemaFormValidate' ) ;
81
+ } ;
82
+
83
+ var tmpl = angular . element ( '<form ng-submit="validateForm()" sf-schema="schema" sf-form="form" sf-model="model"></form>' ) ;
84
+
85
+ $compile ( tmpl ) ( scope ) ;
86
+ $rootScope . $apply ( ) ;
87
+
88
+ var helpBlock = tmpl . children ( ) . find ( 'div.help-block' ) ;
89
+ helpBlock . text ( ) . should . equal ( '' ) ;
90
+ } ) ;
91
+ } )
51
92
} ) ;
You can’t perform that action at this time.
0 commit comments