Spies reflect wrapped function's name & length

This commit is contained in:
Barney Carroll 2016-08-31 11:51:15 +01:00
parent f0888ac7bd
commit 6b922d02ea
2 changed files with 7 additions and 0 deletions

View file

@ -27,6 +27,11 @@ module.exports = new function init() {
if (fn) return fn.apply(this, arguments)
}
if (fn)
Object.defineProperties(spy, {
length: {value: fn.length},
name: {value: fn.name}
})
spy.args = []
spy.callCount = 0
return spy

View file

@ -60,6 +60,8 @@ o.spec("ospec", function() {
var output = spy.call(state, {children: children})
o(spy.length).equals(1)
o(spy.name).equals('view')
o(spy.callCount).equals(1)
o(spy.args.length).equals(1)
o(spy.args[0]).deepEquals({children: children})