diff options
| author | Misko Hevery | 2010-05-10 20:24:20 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-05-10 20:24:20 -0700 |
| commit | 5dda723185a9037b7e92828d32430c21838ee216 (patch) | |
| tree | 15e12ff20e020bb524d704bc7e0d2f8d1f6f1b40 /test/testabilityPatch.js | |
| parent | f5027cc375cf29d8a78679297d9f6bdca9567eb7 (diff) | |
| download | angular.js-5dda723185a9037b7e92828d32430c21838ee216.tar.bz2 | |
improved handling of text fields when formater fails to prevent clobering of field
Diffstat (limited to 'test/testabilityPatch.js')
| -rw-r--r-- | test/testabilityPatch.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js index 4d129f60..d621b1f1 100644 --- a/test/testabilityPatch.js +++ b/test/testabilityPatch.js @@ -1,6 +1,31 @@ jstd = jstestdriver; dump = bind(jstd.console, jstd.console.log); +beforeEach(function(){ + this.addMatchers({ + toBeInvalid: function(){ + var element = jqLite(this.actual); + var hasClass = element.hasClass('ng-validation-error'); + var validationError = element.attr('ng-validation-error'); + this.message = function(){ + if (!hasClass) + return "Expected class 'ng-validation-error' not found."; + return "Expected an error message, but none was found."; + }; + return hasClass && validationError; + }, + + toBeValid: function(){ + var element = jqLite(this.actual); + var hasClass = element.hasClass('ng-validation-error'); + this.message = function(){ + return "Expected to not have class 'ng-validation-error' but found."; + }; + return !hasClass; + } + }); +}); + function nakedExpect(obj) { return expect(angular.fromJson(angular.toJson(obj))); } |
