alsatian
Version:
TypeScript and JavaScript testing framework for beautiful and readable tests
35 lines • 990 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const spying_1 = require("../spying");
class FunctionSpy {
constructor() {
this._calls = [];
}
get calls() {
return this._calls;
}
callsWithArguments(...args) {
return this.calls.filter(call => call.allArgumentsMatch.apply(call, args));
}
call(...args) {
this.calls.push(new spying_1.SpyCall(args));
let returnValue;
if (this._fakeFunction) {
returnValue = this._fakeFunction.apply(this.context, args);
}
if (this.hasReturnValue) {
return this.returnValue;
}
return returnValue;
}
andReturn(returnValue) {
this.returnValue = returnValue;
this.hasReturnValue = true;
}
andCall(fakeFunction) {
this.isStubbed = true;
this._fakeFunction = fakeFunction;
}
}
exports.FunctionSpy = FunctionSpy;
//# sourceMappingURL=function-spy.js.map
;