aboutsummaryrefslogtreecommitdiffstats
path: root/test/matchers.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/matchers.js')
-rw-r--r--test/matchers.js17
1 files changed, 17 insertions, 0 deletions
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);
}
+
});
});