From a87f2fb9e4d65ac5d260e914b5e31aa0e0f47b2c Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 4 Nov 2011 12:33:01 -0700 Subject: refactor(mock): moved mocks into its own module --- test/matchers.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/matchers.js') diff --git a/test/matchers.js b/test/matchers.js index 9923bd7e..fbe86a5a 100644 --- a/test/matchers.js +++ b/test/matchers.js @@ -23,6 +23,13 @@ beforeEach(function() { }; } + function indexOf(array, obj) { + for ( var i = 0; i < array.length; i++) { + if (obj === array[i]) return i; + } + return -1; + } + this.addMatchers({ toBeInvalid: cssMatcher('ng-invalid', 'ng-valid'), toBeValid: cssMatcher('ng-valid', 'ng-invalid'), @@ -84,6 +91,16 @@ beforeEach(function() { toBeOneOf: function() { return indexOf(arguments, this.actual) !== -1; + }, + + toHaveClass: function(clazz) { + this.message = function() { + return "Expected '" + angular.mock.dump(this.actual) + "' to have class '" + clazz + "'."; + }; + return this.actual.hasClass ? + this.actual.hasClass(clazz) : + angular.element(this.actual).hasClass(clazz); } + }); }); -- cgit v1.2.3