Jelajahi Sumber

new arg for spyOnMethod

Adam Shaw 8 tahun lalu
induk
melakukan
ee92ed7f7f
1 mengubah file dengan 6 tambahan dan 2 penghapusan
  1. 6 2
      tests/lib/jasmine-ext.js

+ 6 - 2
tests/lib/jasmine-ext.js

@@ -212,12 +212,16 @@ beforeEach(function() {
 });
 });
 
 
 
 
-function spyOnMethod(Class, methodName) {
+function spyOnMethod(Class, methodName, dontCallThrough) {
 	var origMethod = Class.prototype.hasOwnProperty(methodName) ?
 	var origMethod = Class.prototype.hasOwnProperty(methodName) ?
 		Class.prototype[methodName] :
 		Class.prototype[methodName] :
 		null;
 		null;
 
 
-	var spy = spyOn(Class.prototype, methodName).and.callThrough();
+	var spy = spyOn(Class.prototype, methodName);
+
+	if (!dontCallThrough) {
+		spy = spy.and.callThrough();
+	}
 
 
 	spy.restore = function() {
 	spy.restore = function() {
 		if (origMethod) {
 		if (origMethod) {