UNPKG

990 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const spying_1 = require("../spying");
4class FunctionSpy {
5 constructor() {
6 this._calls = [];
7 }
8 get calls() {
9 return this._calls;
10 }
11 callsWithArguments(...args) {
12 return this.calls.filter(call => call.allArgumentsMatch.apply(call, args));
13 }
14 call(...args) {
15 this.calls.push(new spying_1.SpyCall(args));
16 let returnValue;
17 if (this._fakeFunction) {
18 returnValue = this._fakeFunction.apply(this.context, args);
19 }
20 if (this.hasReturnValue) {
21 return this.returnValue;
22 }
23 return returnValue;
24 }
25 andReturn(returnValue) {
26 this.returnValue = returnValue;
27 this.hasReturnValue = true;
28 }
29 andCall(fakeFunction) {
30 this.isStubbed = true;
31 this._fakeFunction = fakeFunction;
32 }
33}
34exports.FunctionSpy = FunctionSpy;
35//# sourceMappingURL=function-spy.js.map
\No newline at end of file