Test for onbeforeremove delayed resolution

This commit is contained in:
Barney Carroll 2016-12-30 19:31:51 +00:00
parent 8746e397b7
commit 3fa771ac28

View file

@ -158,14 +158,14 @@ o.spec("onbeforeremove", function() {
render(root, vnodes)
render(root, updated)
o(root.childNodes.length).equals(2)
o(root.firstChild.firstChild.nodeValue).equals("1")
callAsync(function() {
o(root.childNodes.length).equals(1)
o(root.firstChild.firstChild.nodeValue).equals("2")
done()
})
})
@ -184,4 +184,25 @@ o.spec("onbeforeremove", function() {
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()
})
})
})
})