Remove old body property references.

The body must be consumed through the `text`, `json`, `formData`, or
`blob` functions.
This commit is contained in:
David Graham 2014-11-01 17:57:43 -06:00
Родитель a1c1b79abf
Коммит 531c68f04b
1 изменённых файлов: 17 добавлений и 10 удалений

Просмотреть файл

@ -11,7 +11,9 @@ var blobSupport = (function() {
asyncTest('populates response body', 2, function() {
fetch('/hello').then(function(response) {
equal(response.status, 200)
equal(response.body, 'hi')
return response.text()
}).then(function(body) {
equal(body, 'hi')
start()
})
})
@ -23,9 +25,10 @@ asyncTest('sends request headers', 2, function() {
'X-Test': '42'
}
}).then(function(response) {
var headers = JSON.parse(response.body).headers
equal(headers['accept'], 'application/json')
equal(headers['x-test'], '42')
return response.json()
}).then(function(json) {
equal(json.headers['accept'], 'application/json')
equal(json.headers['x-test'], '42')
start()
})
})
@ -41,7 +44,9 @@ asyncTest('parses response headers', 2, function() {
asyncTest('resolves promise on 500 error', 2, function() {
fetch('/boom').then(function(response) {
equal(response.status, 500)
equal(response.body, 'boom')
return response.text()
}).then(function(body) {
equal(body, 'boom')
start()
})
})
@ -113,9 +118,10 @@ asyncTest('post sends encoded body', 2, function() {
nil: null
}
}).then(function(response) {
var request = JSON.parse(response.body);
equal(request.method, 'POST')
equal(request.data, 'name=Hubot&title=Hubot+Robawt&nil=')
return response.json()
}).then(function(json) {
equal(json.method, 'POST')
equal(json.data, 'name=Hubot&title=Hubot+Robawt&nil=')
start()
})
})
@ -125,8 +131,9 @@ asyncTest('post sets content-type header', 1, function() {
method: 'post',
body: new FormData()
}).then(function(response) {
var request = JSON.parse(response.body);
ok(/^multipart\/form-data;/.test(request.headers['content-type']))
return response.json()
}).then(function(json) {
ok(/^multipart\/form-data;/.test(json.headers['content-type']))
start()
})
})