aboutsummaryrefslogtreecommitdiffstats
path: root/test/matchers.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/matchers.js')
-rw-r--r--test/matchers.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/matchers.js b/test/matchers.js
index 13d284e6..44d6b61e 100644
--- a/test/matchers.js
+++ b/test/matchers.js
@@ -190,3 +190,17 @@ jasmine.Matchers.prototype.toThrow = function(expected) {
return result;
};
+
+
+/**
+ * Create jasmine.Spy on given method, but ignore calls without arguments
+ * This is helpful when need to spy only setter methods and ignore getters
+ */
+function spyOnlyCallsWithArgs(obj, method) {
+ var spy = spyOn(obj, method);
+ obj[method] = function() {
+ if (arguments.length) return spy.apply(this, arguments);
+ return spy.originalValue.apply(this);
+ };
+ return spy;
+}