mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-02 20:24:45 +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);
|
callback(expectation.code, expectation.response);
|
||||||
});
|
});
|
||||||
|
// TODO(vojta): return mock request object
|
||||||
};
|
};
|
||||||
self.xhr.expectations = expectations;
|
self.xhr.expectations = expectations;
|
||||||
self.xhr.requests = requests;
|
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>
|
* <li><tt>X-Requested-With</tt>: <tt>XMLHttpRequest</tt></li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
|
* @returns {XMLHttpRequest|undefined} Raw XMLHttpRequest object or undefined when JSONP method
|
||||||
|
*
|
||||||
* @description
|
* @description
|
||||||
* Send ajax request
|
* Send ajax request
|
||||||
|
*
|
||||||
|
* TODO(vojta): change signature of this method to (method, url, data, headers, callback)
|
||||||
*/
|
*/
|
||||||
self.xhr = function(method, url, post, callback, headers) {
|
self.xhr = function(method, url, post, callback, headers) {
|
||||||
outstandingRequestCount ++;
|
outstandingRequestCount ++;
|
||||||
|
|
@ -124,6 +128,7 @@ function Browser(window, document, body, XHR, $log, $sniffer) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.send(post || '');
|
xhr.send(post || '');
|
||||||
|
return xhr;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,10 @@ describe('browser', function() {
|
||||||
expect(code).toEqual(202);
|
expect(code).toEqual(202);
|
||||||
expect(response).toEqual('RESPONSE');
|
expect(response).toEqual('RESPONSE');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return raw xhr object', function() {
|
||||||
|
expect(browser.xhr('GET', '/url', null, noop)).toBe(xhr);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('defer', function() {
|
describe('defer', function() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue