Merge pull request #1287 from barneycarroll/ospec-spy-wrapping

[ospec] Spies reflect wrapped function's name & length
This commit is contained in:
Leo Horie 2016-09-02 10:34:29 -04:00 committed by GitHub
commit 9fbcea2d06
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})