From 73c8593077155a9f2e8ef42efd4c497eba0bef4f Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 23 Mar 2012 13:41:48 -0700 Subject: feat(http): added params parameter The params parameter can now be used to serialize parameters in the URLs. The serialization does proper escaping and JSON encoding if it is an object. --- test/service/httpSpec.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test') diff --git a/test/service/httpSpec.js b/test/service/httpSpec.js index 43dbf3af..ab50827c 100644 --- a/test/service/httpSpec.js +++ b/test/service/httpSpec.js @@ -132,6 +132,26 @@ describe('$http', function() { // TODO(vojta): test passing timeout + describe('params', function() { + it('should do basic request with params and encode', inject(function($httpBackend, $http) { + $httpBackend.expect('GET', '/url?a%3D=%3F%26&b=2').respond(''); + $http({url: '/url', params: {'a=':'?&', b:2}, method: 'GET'}); + })); + + + it('should merge params if url contains some already', inject(function($httpBackend, $http) { + $httpBackend.expect('GET', '/url?c=3&a=1&b=2').respond(''); + $http({url: '/url?c=3', params: {a:1, b:2}, method: 'GET'}); + })); + + + it('should jsonify objects in params map', inject(function($httpBackend, $http) { + $httpBackend.expect('GET', '/url?a=1&b=%7B%22c%22%3A3%7D').respond(''); + $http({url: '/url', params: {a:1, b:{c:3}}, method: 'GET'}); + })); + }); + + describe('callbacks', function() { it('should pass in the response object when a request is successful', function() { -- cgit v1.2.3