diff options
| author | Misko Hevery | 2010-04-16 17:03:06 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-04-16 17:03:06 -0700 |
| commit | 6470b48ce022885551e83c9f5fd8a90fbc6ff80e (patch) | |
| tree | 36b189ea3fdb7ab2026d06fa5dd0961e51d881e0 /test | |
| parent | deb86fe357a901889bc4289087f0b9e69cb8a302 (diff) | |
| download | angular.js-6470b48ce022885551e83c9f5fd8a90fbc6ff80e.tar.bz2 | |
validation issues fixed
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(); |
