From 3171f215910255938c179d8243480fbaeebc77cf Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Thu, 23 Feb 2012 22:50:02 -0800 Subject: fix($httpBackend): Set current url, if not defined or empty string Reason to fix this was the fact that with undefined url, it ended up with weird exception (Cannot call method 'replace' of undefined), which was more confusing than helpful. jQuery.ajax() does request to current url, if url is not specified, so I decided for this solution.--- test/service/httpBackendSpec.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') diff --git a/test/service/httpBackendSpec.js b/test/service/httpBackendSpec.js index 55d1a48a..820099e8 100644 --- a/test/service/httpBackendSpec.js +++ b/test/service/httpBackendSpec.js @@ -168,6 +168,17 @@ describe('$httpBackend', function() { }); + it('should set url to current location if not specified or empty string', function() { + $backend('JSONP', undefined, null, callback); + expect($browser.$$scripts[0].url).toBe($browser.url()); + $browser.$$scripts.shift(); + + $backend('JSONP', '', null, callback); + expect($browser.$$scripts[0].url).toBe($browser.url()); + $browser.$$scripts.shift(); + }); + + // TODO(vojta): test whether it fires "async-start" // TODO(vojta): test whether it fires "async-end" on both success and error }); -- cgit v1.2.3