diff options
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))); } |
