"use strict";
var spy_call_1 = require("./spy-call");
var Spy = (function () {
function Spy(originalFunction, originalContext) {
this._calls = [];
this._originalFunction = originalFunction;
this._originalContext = originalContext;
}
Object.defineProperty(Spy.prototype, "calls", {
get: function () {
return this._calls;
},
enumerable: true,
configurable: true
});
Spy.prototype.call = function (args) {
this.calls.push(new spy_call_1.SpyCall(args));
var returnValue;
if (!this._isStubbed) {
returnValue = this._originalFunction.apply(this._originalContext, args);
}
if (this._hasReturnValue) {
return this._returnValue;
}
return returnValue;
};
Spy.prototype.return = function (returnValue) {
this._returnValue = returnValue;
this._hasReturnValue = true;
};
Spy.prototype.andCallThrough = function () {
this._isStubbed = false;
};
Spy.prototype.andStub = function () {
this._isStubbed = true;
};
return Spy;
}());
exports.Spy = Spy;
//# sourceMappingURL=spy.js.map |