Skip to content

Commit

Permalink
Test network failure rejects promise.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgraham committed Oct 13, 2014
1 parent 9bdada5 commit ce9abcc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ MockXHR.responses = {
'/boom': function(xhr) {
xhr.respond(500, 'boom')
},
'/error': function(xhr) {
xhr.error()
},
'/json': function(xhr) {
xhr.respond(200, JSON.stringify({name: 'Hubot', login: 'hubot'}))
},
Expand Down Expand Up @@ -61,6 +64,13 @@ asyncTest('resolves promise on 500 error', 2, function() {
})
})

asyncTest('rejects promise for network error', 1, function() {
fetch('/error').catch(function() {
ok(true)
start()
})
})

asyncTest('resolves text promise', 1, function() {
fetch('/hello').then(function(response) {
return response.text()
Expand Down

0 comments on commit ce9abcc

Please sign in to comment.