mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-24 10:20:23 +00:00
fix($http): remove support for PATCH + better whenXXX, expectXXX api
- there are too many unknowns about PATCH, so I'm dropping its support until we know that this is actually useful - expectGET, expectHEAD and expectJSON (and the same for whenXXX) should not require response data to be specified
This commit is contained in:
parent
e7a23e4b65
commit
46691c2721
4 changed files with 12 additions and 18 deletions
12
src/angular-mocks.js
vendored
12
src/angular-mocks.js
vendored
|
|
@ -748,11 +748,17 @@ function createHttpBackendMock($delegate, $defer) {
|
|||
|
||||
|
||||
function createShortMethods(prefix) {
|
||||
angular.forEach(['GET', 'PUT', 'POST', 'DELETE', 'PATCH', 'JSONP'], function(method) {
|
||||
$httpBackend[prefix + method] = function(url, data, headers) {
|
||||
return $httpBackend[prefix](method, url, data, headers)
|
||||
angular.forEach(['GET', 'DELETE', 'JSONP'], function(method) {
|
||||
$httpBackend[prefix + method] = function(url, headers) {
|
||||
return $httpBackend[prefix](method, url, undefined, headers)
|
||||
}
|
||||
});
|
||||
|
||||
angular.forEach(['PUT', 'POST'], function(method) {
|
||||
$httpBackend[prefix + method] = function(url, data, headers) {
|
||||
return $httpBackend[prefix](method, url, data, headers)
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ function $HttpProvider() {
|
|||
* @param {Object=} config Optional configuration object
|
||||
* @returns {XhrFuture} Future object
|
||||
*/
|
||||
createShortMethods('get', 'delete', 'head', 'patch', 'jsonp');
|
||||
createShortMethods('get', 'delete', 'head', 'jsonp');
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
|
|
|
|||
4
test/angular-mocksSpec.js
vendored
4
test/angular-mocksSpec.js
vendored
|
|
@ -819,9 +819,9 @@ describe('ngMock', function() {
|
|||
});
|
||||
|
||||
|
||||
describe('expect/when shorcuts', function() {
|
||||
describe('expect/when shortcuts', function() {
|
||||
angular.forEach(['expect', 'when'], function(prefix) {
|
||||
angular.forEach(['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'JSONP'], function(method) {
|
||||
angular.forEach(['GET', 'POST', 'PUT', 'DELETE', 'JSONP'], function(method) {
|
||||
var shortcut = prefix + method;
|
||||
it('should provide ' + shortcut + ' shortcut method', function() {
|
||||
hb[shortcut]('/foo').respond('bar');
|
||||
|
|
|
|||
|
|
@ -479,18 +479,6 @@ describe('$http', function() {
|
|||
});
|
||||
|
||||
|
||||
it('should have patch()', function() {
|
||||
$httpBackend.expect('PATCH', '/url').respond('');
|
||||
$http.patch('/url');
|
||||
});
|
||||
|
||||
|
||||
it('patch() should allow config param', function() {
|
||||
$httpBackend.expect('PATCH', '/url', undefined, checkHeader('Custom', 'Header')).respond('');
|
||||
$http.patch('/url', {headers: {'Custom': 'Header'}});
|
||||
});
|
||||
|
||||
|
||||
it('should have post()', function() {
|
||||
$httpBackend.expect('POST', '/url', 'some-data').respond('');
|
||||
$http.post('/url', 'some-data');
|
||||
|
|
|
|||
Loading…
Reference in a new issue