Add functionality for inspecting arbitrary past calls
This made it much easier to debug multiple calls while developing this patch.
This commit is contained in:
parent
89d833e909
commit
f844cc8134
3 changed files with 10 additions and 3 deletions
|
|
@ -111,6 +111,7 @@ o.spec("call()", function() {
|
||||||
|
|
||||||
o(spy.callCount).equals(1)
|
o(spy.callCount).equals(1)
|
||||||
o(spy.args[0]).equals(1)
|
o(spy.args[0]).equals(1)
|
||||||
|
o(spy.calls[0]).deepEquals([1])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ else window.o = m()
|
||||||
var spy = function() {
|
var spy = function() {
|
||||||
spy.this = this
|
spy.this = this
|
||||||
spy.args = [].slice.call(arguments)
|
spy.args = [].slice.call(arguments)
|
||||||
|
spy.calls.push({this: this, args: spy.args})
|
||||||
spy.callCount++
|
spy.callCount++
|
||||||
|
|
||||||
if (fn) return fn.apply(this, arguments)
|
if (fn) return fn.apply(this, arguments)
|
||||||
|
|
@ -59,6 +60,7 @@ else window.o = m()
|
||||||
name: {value: fn.name}
|
name: {value: fn.name}
|
||||||
})
|
})
|
||||||
spy.args = []
|
spy.args = []
|
||||||
|
spy.calls = []
|
||||||
spy.callCount = 0
|
spy.callCount = 0
|
||||||
return spy
|
return spy
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -206,6 +206,8 @@ o.spec("ospec", function() {
|
||||||
o(spy.callCount).equals(1)
|
o(spy.callCount).equals(1)
|
||||||
o(spy.args.length).equals(1)
|
o(spy.args.length).equals(1)
|
||||||
o(spy.args[0]).equals(1)
|
o(spy.args[0]).equals(1)
|
||||||
|
o(spy.calls.length).equals(1)
|
||||||
|
o(spy.calls[0]).deepEquals({this: undefined, args: [1]})
|
||||||
})
|
})
|
||||||
o("spy wrapping", function() {
|
o("spy wrapping", function() {
|
||||||
var spy = o.spy(function view(vnode){
|
var spy = o.spy(function view(vnode){
|
||||||
|
|
@ -223,6 +225,8 @@ o.spec("ospec", function() {
|
||||||
o(spy.callCount).equals(1)
|
o(spy.callCount).equals(1)
|
||||||
o(spy.args.length).equals(1)
|
o(spy.args.length).equals(1)
|
||||||
o(spy.args[0]).deepEquals({children: children})
|
o(spy.args[0]).deepEquals({children: children})
|
||||||
|
o(spy.calls.length).equals(1)
|
||||||
|
o(spy.calls[0]).deepEquals({this: state, args: [{children: children}]})
|
||||||
o(state).deepEquals({drawn: true})
|
o(state).deepEquals({drawn: true})
|
||||||
o(output).deepEquals({tag: "div", children: children})
|
o(output).deepEquals({tag: "div", children: children})
|
||||||
})
|
})
|
||||||
|
|
@ -461,7 +465,7 @@ o.spec("ospec", function() {
|
||||||
oo.spec("nested 3", function () {
|
oo.spec("nested 3", function () {
|
||||||
oo("", function() {
|
oo("", function() {
|
||||||
oo(true).equals(true)
|
oo(true).equals(true)
|
||||||
|
|
||||||
return {then: function() {}}
|
return {then: function() {}}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
@ -490,10 +494,10 @@ o.spec("ospec", function() {
|
||||||
o(diff >= 50).equals(true)
|
o(diff >= 50).equals(true)
|
||||||
o(diff < 80).equals(true)
|
o(diff < 80).equals(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
oo("", function() {
|
oo("", function() {
|
||||||
oo(true).equals(true)
|
oo(true).equals(true)
|
||||||
|
|
||||||
return {then: function() {}}
|
return {then: function() {}}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue