Test for onbeforeremove delayed resolution
This commit is contained in:
parent
8746e397b7
commit
3fa771ac28
1 changed files with 24 additions and 3 deletions
|
|
@ -158,14 +158,14 @@ o.spec("onbeforeremove", function() {
|
||||||
|
|
||||||
render(root, vnodes)
|
render(root, vnodes)
|
||||||
render(root, updated)
|
render(root, updated)
|
||||||
|
|
||||||
o(root.childNodes.length).equals(2)
|
o(root.childNodes.length).equals(2)
|
||||||
o(root.firstChild.firstChild.nodeValue).equals("1")
|
o(root.firstChild.firstChild.nodeValue).equals("1")
|
||||||
|
|
||||||
callAsync(function() {
|
callAsync(function() {
|
||||||
o(root.childNodes.length).equals(1)
|
o(root.childNodes.length).equals(1)
|
||||||
o(root.firstChild.firstChild.nodeValue).equals("2")
|
o(root.firstChild.firstChild.nodeValue).equals("2")
|
||||||
|
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
@ -184,4 +184,25 @@ o.spec("onbeforeremove", function() {
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
o("awaits promise resolution before removing the node", function(done) {
|
||||||
|
var view = o.spy()
|
||||||
|
var onremove = o.spy()
|
||||||
|
var onbeforeremove = function(){return new Promise(function(resolve){callAsync(resolve)})}
|
||||||
|
var component = {
|
||||||
|
onbeforeremove: onbeforeremove,
|
||||||
|
onremove: onremove,
|
||||||
|
view: view,
|
||||||
|
}
|
||||||
|
render(root, [{tag: component}])
|
||||||
|
render(root, [])
|
||||||
|
|
||||||
|
callAsync(function(){
|
||||||
|
o(onremove.callCount).equals(0)
|
||||||
|
|
||||||
|
callAsync(function() {
|
||||||
|
o(onremove.callCount).equals(1)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue