Test branched rejection handler resolution
This commit is contained in:
parent
b4f1f35c54
commit
d74fa75832
2 changed files with 42 additions and 1 deletions
|
|
@ -403,6 +403,24 @@ o.spec("promise", function() {
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
o("triggers all branched rejection handlers upon rejection", function(done) {
|
||||||
|
var promise = Promise.reject()
|
||||||
|
var then = o.spy()
|
||||||
|
var catch1 = o.spy()
|
||||||
|
var catch2 = o.spy()
|
||||||
|
var catch3 = o.spy()
|
||||||
|
|
||||||
|
promise.catch(catch1)
|
||||||
|
promise.then(then, catch2).catch(catch3)
|
||||||
|
|
||||||
|
promise.then(null, function(){
|
||||||
|
o(catch1.callCount).equals(1, "first branch catch triggers")
|
||||||
|
o(then.callCount).equals(0, "second branch then resolution handler doesn't trigger")
|
||||||
|
o(catch2.callCount).equals(1, "second branch then rejection handler triggers")
|
||||||
|
o(catch3.callCount).equals(1, "second branch subseqent catch triggers")
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
o("does not absorb resolved promise via static rejector", function(done) {
|
o("does not absorb resolved promise via static rejector", function(done) {
|
||||||
var promise = Promise.reject(Promise.resolve(1))
|
var promise = Promise.reject(Promise.resolve(1))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -377,5 +377,28 @@ o.spec("xhr", function() {
|
||||||
o(e.message).equals("error")
|
o(e.message).equals("error")
|
||||||
}).then(done)
|
}).then(done)
|
||||||
})
|
})
|
||||||
|
o("triggers all branched catches upon rejection", function(done) {
|
||||||
|
mock.$defineRoutes({
|
||||||
|
"GET /item": function(request) {
|
||||||
|
return {status: 500, responseText: "error"}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
var request = xhr({method: "GET", url: "/item"})
|
||||||
|
var then = o.spy()
|
||||||
|
var catch1 = o.spy()
|
||||||
|
var catch2 = o.spy()
|
||||||
|
var catch3 = o.spy()
|
||||||
|
|
||||||
|
request.catch(catch1)
|
||||||
|
request.then(then, catch2).catch(catch3)
|
||||||
|
|
||||||
|
setTimeout(function(){
|
||||||
|
o(catch1.callCount).equals(1, "first branch catch triggers")
|
||||||
|
o(then.callCount).equals(0, "second branch then resolution handler doesn't trigger")
|
||||||
|
o(catch2.callCount).equals(1, "second branch then rejection handler triggers")
|
||||||
|
o(catch3.callCount).equals(1, "second branch subseqent catch triggers")
|
||||||
|
done()
|
||||||
|
}, 10)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue