test.js 358 字节
Newer Older
D
David Graham 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
MockXHR.responses = {
  '/hello': function(xhr) {
    xhr.respond(200, 'hi')
  },
  '/boom': function(xhr) {
    xhr.respond(500, 'boom')
  }
}

window.XMLHttpRequest = MockXHR

asyncTest('populates response body', 2, function() {
  fetch('/hello').then(function(response) {
    equal(response.status, 200)
    equal(response.body, 'hi')
    start()
  })
})