diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/widgetsSpec.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index ae6a17df..ecc00d05 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -60,7 +60,7 @@ describe("input widget", function(){ expect(scope.$element[0].checked).toEqual(false); }); - it("should process ng-validation", function(){ + it("should process ng-validate", function(){ compile('<input type="text" name="price" value="abc" ng-validate="number"/>'); expect(element.hasClass('ng-validation-error')).toBeTruthy(); expect(element.attr('ng-validation-error')).toEqual('Not a number'); @@ -76,6 +76,19 @@ describe("input widget", function(){ expect(element.attr('ng-validation-error')).toEqual('Not a number'); }); + it("should not call validator if undefinde/empty", function(){ + var lastValue = "NOT_CALLED"; + angularValidator.myValidator = function(value){lastValue = value;}; + compile('<input type="text" name="url" ng-validate="myValidator"/>'); + expect(lastValue).toEqual("NOT_CALLED"); + + scope.url = 'http://server'; + scope.$eval(); + expect(lastValue).toEqual("http://server"); + + delete angularValidator.myValidator; + }); + it("should ignore disabled widgets", function(){ compile('<input type="text" name="price" ng-required disabled/>'); expect(element.hasClass('ng-validation-error')).toBeFalsy(); |
