Spies reflect wrapped function's name & length
This commit is contained in:
parent
f0888ac7bd
commit
6b922d02ea
2 changed files with 7 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue