closes #1294
This commit is contained in:
parent
b2cedf7b0a
commit
ade541bd61
2 changed files with 4 additions and 3 deletions
|
@ -1,11 +1,12 @@
|
||||||
function spy(func) {
|
function spy(func) {
|
||||||
|
|
||||||
function wrapper(...args) {
|
function wrapper(...args) {
|
||||||
|
// using ...args instead of arguments to store "real" array in wrapper.calls
|
||||||
wrapper.calls.push(args);
|
wrapper.calls.push(args);
|
||||||
return func.apply(this, arguments);
|
return func.apply(this, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.calls = [];
|
wrapper.calls = [];
|
||||||
|
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Here we can use `calls.push(args)` to store all arguments in the log and `f.apply(this, args)` to forward the call.
|
The wrapper returned by `spy(f)` should store all arguments and then use `f.apply` to forward the call.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue