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