Skip to content

Commit d5a79ab

Browse files
committed
trying to add (and failing) test for issue 602
1 parent bb87620 commit d5a79ab

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

test/directives/sf-messages-test.js

+41
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,45 @@ describe('directive',function() {
4848

4949
});
5050
});
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+
})
5192
});

0 commit comments

Comments
 (0)