extend rejection reason w/ json error on request error
This commit is contained in:
parent
6e3ce0aeb5
commit
36e6894859
2 changed files with 18 additions and 1 deletions
|
|
@ -260,9 +260,22 @@ o.spec("xhr", function() {
|
|||
}
|
||||
})
|
||||
xhr({method: "GET", url: "/item"}).catch(function(e) {
|
||||
o(e instanceof Error).equals(true)
|
||||
o(e.message).equals(JSON.stringify({error: "error"}))
|
||||
}).map(done)
|
||||
})
|
||||
o("extends Error with JSON response", function(done) {
|
||||
mock.$defineRoutes({
|
||||
"GET /item": function(request) {
|
||||
return {status: 500, responseText: JSON.stringify({message: "error", stack: "error on line 1"})}
|
||||
}
|
||||
})
|
||||
xhr({method: "GET", url: "/item"}).catch(function(e) {
|
||||
o(e instanceof Error).equals(true)
|
||||
o(e.message).equals("error")
|
||||
o(e.stack).equals("error on line 1")
|
||||
}).map(done)
|
||||
})
|
||||
o("rejects on non-JSON server error", function(done) {
|
||||
mock.$defineRoutes({
|
||||
"GET /item": function(request) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue