提交 219bda9a 编写于 作者: D David Graham

Test response header parsing.

上级 41b622d9
......@@ -10,6 +10,13 @@ MockXHR.responses = {
},
'/json-error': function(xhr) {
xhr.respond(200, 'not json {')
},
'/headers': function(xhr) {
headers = [
'Date: Mon, 13 Oct 2014 21:02:27 GMT',
'Content-Type: text/html; charset=utf-8'
].join('\r\n')
xhr.respond(200, 'hi', headers + '\r\n')
}
}
......@@ -24,7 +31,7 @@ asyncTest('populates response body', 3, function() {
})
})
asyncTest('sends headers', 2, function() {
asyncTest('sends request headers', 2, function() {
fetch('/hello', {
headers: {
'Accept': 'application/json',
......@@ -38,6 +45,14 @@ asyncTest('sends headers', 2, function() {
})
})
asyncTest('parses response headers', 2, function() {
fetch('/headers').then(function(response) {
equal(response.headers.get('Date'), 'Mon, 13 Oct 2014 21:02:27 GMT')
equal(response.headers.get('Content-Type'), 'text/html; charset=utf-8')
start()
})
})
asyncTest('resolves text promise', 1, function() {
fetch('/hello').then(function(response) {
return response.text()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册