[ospec] allow spy to wrap functions

This commit is contained in:
Barney Carroll 2016-08-30 17:10:21 +01:00
parent 9c4ebc8667
commit 211802793d
2 changed files with 21 additions and 1 deletions

View file

@ -49,6 +49,23 @@ o.spec("ospec", function() {
o(spy.args.length).equals(1)
o(spy.args[0]).equals(1)
})
o("spy wrapping", function() {
var spy = o.spy(function view(vnode){
this.drawn = true
return {tag: "div", children: vnode.children}
})
var children = [""]
var state = {}
var output = spy.call(state, {children: children})
o(spy.callCount).equals(1)
o(spy.args.length).equals(1)
o(spy.args[0]).deepEquals({children: children})
o(state).deepEquals({drawn: true})
o(output).deepEquals({tag: "div", children: children})
})
})
o.spec("async", function() {
var a = 0, b = 0