Add support for options.headers in m.request + tests/docs

I also had to edit the mocks accordingly, so I could inspect the headers set.
This commit is contained in:
impinball 2016-12-30 02:52:00 -05:00
parent 00a3ce3657
commit 95d738bc71
4 changed files with 66 additions and 5 deletions

View file

@ -14,7 +14,13 @@ module.exports = function() {
var $window = {
XMLHttpRequest: function XMLHttpRequest() {
var args = {}
this.setRequestHeader = function(header, value) {}
var headers = {}
this.setRequestHeader = function(header, value) {
headers[header] = value
}
this.getRequestHeader = function(header) {
return headers[header]
}
this.open = function(method, url, async, user, password) {
var urlData = parseURL(url, {protocol: "http:", hostname: "localhost", port: "", pathname: "/"})
args.method = method