diff options
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/FakeHttpProvider2.js | 10 | ||||
-rw-r--r-- | helpers/FakeXMLHttpRequest.js | 7 |
2 files changed, 17 insertions, 0 deletions
diff --git a/helpers/FakeHttpProvider2.js b/helpers/FakeHttpProvider2.js index 0f26d84b..e287a074 100644 --- a/helpers/FakeHttpProvider2.js +++ b/helpers/FakeHttpProvider2.js @@ -15,11 +15,21 @@ FakeHttpProvider2.prototype.injectResultList = function (list) { FakeHttpProvider2.prototype.getResponse = function () { var result = this.resultList[this.counter]; this.counter++; + + // add fallback result value + if(!result) + result = { + result: undefined + }; + if (result.type === 'batch') { this.injectBatchResults(result.result); } else { this.injectResult(result.result); } + + this.counter = 0; + return this.response; }; diff --git a/helpers/FakeXMLHttpRequest.js b/helpers/FakeXMLHttpRequest.js index a67d7f74..6dc35b98 100644 --- a/helpers/FakeXMLHttpRequest.js +++ b/helpers/FakeXMLHttpRequest.js @@ -6,6 +6,9 @@ var FakeXMLHttpRequest = function () { this.readyState = 4; this.onreadystatechange = null; this.async = false; + this.headers = { + 'Content-Type': 'text/plain' + }; }; FakeXMLHttpRequest.prototype.open = function (method, host, async) { @@ -15,6 +18,10 @@ FakeXMLHttpRequest.prototype.open = function (method, host, async) { this.async = async; }; +FakeXMLHttpRequest.prototype.setRequestHeader = function(name, value) { + this.headers[name] = value; +}; + FakeXMLHttpRequest.prototype.send = function (payload) { assert.equal(typeof payload, 'string'); if (this.async) { |