mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 15:40:22 +00:00
feat($browser): xhr returns raw request object
This commit is contained in:
parent
a035e88397
commit
0c8b35681e
3 changed files with 10 additions and 0 deletions
1
src/angular-mocks.js
vendored
1
src/angular-mocks.js
vendored
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue