diff options
| -rw-r--r-- | src/angular-mocks.js | 1 | ||||
| -rw-r--r-- | src/service/browser.js | 5 | ||||
| -rw-r--r-- | test/service/browserSpecs.js | 4 |
3 files changed, 10 insertions, 0 deletions
diff --git a/src/angular-mocks.js b/src/angular-mocks.js index f5907a42..73bc4cbd 100644 --- a/src/angular-mocks.js +++ b/src/angular-mocks.js @@ -120,6 +120,7 @@ angular.module.ngMock.$Browser = function() { }); callback(expectation.code, expectation.response); }); + // TODO(vojta): return mock request object }; self.xhr.expectations = expectations; self.xhr.requests = requests; diff --git a/src/service/browser.js b/src/service/browser.js index 2e2c07e8..da82b9b0 100644 --- a/src/service/browser.js +++ b/src/service/browser.js @@ -90,8 +90,12 @@ function Browser(window, document, body, XHR, $log, $sniffer) { * <li><tt>X-Requested-With</tt>: <tt>XMLHttpRequest</tt></li> * </ul> * + * @returns {XMLHttpRequest|undefined} Raw XMLHttpRequest object or undefined when JSONP method + * * @description * Send ajax request + * + * TODO(vojta): change signature of this method to (method, url, data, headers, callback) */ self.xhr = function(method, url, post, callback, headers) { outstandingRequestCount ++; @@ -124,6 +128,7 @@ function Browser(window, document, body, XHR, $log, $sniffer) { } }; xhr.send(post || ''); + return xhr; } }; diff --git a/test/service/browserSpecs.js b/test/service/browserSpecs.js index 5234f0be..7e50a280 100644 --- a/test/service/browserSpecs.js +++ b/test/service/browserSpecs.js @@ -223,6 +223,10 @@ describe('browser', function() { expect(code).toEqual(202); expect(response).toEqual('RESPONSE'); }); + + it('should return raw xhr object', function() { + expect(browser.xhr('GET', '/url', null, noop)).toBe(xhr); + }); }); describe('defer', function() { |
