Test branched rejection handler resolution
This commit is contained in:
parent
b4f1f35c54
commit
d74fa75832
2 changed files with 42 additions and 1 deletions
|
|
@ -336,7 +336,7 @@ o.spec("xhr", function() {
|
|||
}
|
||||
})
|
||||
var promise = xhr("/item", {background: true}).then(function() {})
|
||||
|
||||
|
||||
setTimeout(function() {
|
||||
o(complete.callCount).equals(0)
|
||||
done()
|
||||
|
|
@ -377,5 +377,28 @@ o.spec("xhr", function() {
|
|||
o(e.message).equals("error")
|
||||
}).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