Add support for setting responseType of xhr via m.request options
This commit is contained in:
parent
d64e0a950f
commit
af90b6b4a6
4 changed files with 18 additions and 0 deletions
|
|
@ -76,6 +76,8 @@ module.exports = function($window, Promise) {
|
|||
if (args.withCredentials) xhr.withCredentials = args.withCredentials
|
||||
|
||||
if (args.timeout) xhr.timeout = args.timeout
|
||||
|
||||
if (args.responseType) xhr.responseType = args.responseType
|
||||
|
||||
for (var key in args.headers) if ({}.hasOwnProperty.call(args.headers, key)) {
|
||||
xhr.setRequestHeader(key, args.headers[key])
|
||||
|
|
|
|||
|
|
@ -449,6 +449,20 @@ o.spec("xhr", function() {
|
|||
}
|
||||
})
|
||||
})
|
||||
o("set responseType to xhr instance", function() {
|
||||
mock.$defineRoutes({
|
||||
"GET /item": function() {
|
||||
return {status: 200, responseText: ""}
|
||||
}
|
||||
})
|
||||
return xhr({
|
||||
method: "GET", url: "/item",
|
||||
responseType: "blob",
|
||||
config: function(xhr) {
|
||||
o(xhr.responseType).equals("blob")
|
||||
}
|
||||
})
|
||||
})
|
||||
/*o("data maintains after interpolate", function() {
|
||||
mock.$defineRoutes({
|
||||
"PUT /items/:x": function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue