diff options
| author | Igor Minar | 2011-07-12 00:47:07 -0700 | 
|---|---|---|
| committer | Igor Minar | 2011-07-13 16:21:08 -0700 | 
| commit | 8a8a2cf4623708b69dba3816e22b01407e338b73 (patch) | |
| tree | 8f4ae1d8658c0a1cff9497e60551890478cd3a04 /test/BrowserSpecs.js | |
| parent | 47efe44a1d8c9a40526a610b5ee31c44288adee0 (diff) | |
| download | angular.js-8a8a2cf4623708b69dba3816e22b01407e338b73.tar.bz2 | |
refactor($browser.xhr): use $browser.addJs for JSONP
There is no reason why we shouldn't reuse $browser.addJs for JSONP
requests.
Diffstat (limited to 'test/BrowserSpecs.js')
| -rw-r--r-- | test/BrowserSpecs.js | 14 | 
1 files changed, 7 insertions, 7 deletions
diff --git a/test/BrowserSpecs.js b/test/BrowserSpecs.js index f87e98f8..d6eb5697 100644 --- a/test/BrowserSpecs.js +++ b/test/BrowserSpecs.js @@ -1,6 +1,6 @@  describe('browser', function(){ -  var browser, fakeWindow, xhr, logs, scripts, setTimeoutQueue; +  var browser, fakeWindow, xhr, logs, scripts, removedScripts, setTimeoutQueue;    function fakeSetTimeout(fn) {      setTimeoutQueue.push(fn); @@ -17,13 +17,15 @@ describe('browser', function(){    beforeEach(function(){      setTimeoutQueue = [];      scripts = []; +    removedScripts = [];      xhr = null;      fakeWindow = {        location: {href:"http://server"},        setTimeout: fakeSetTimeout      }; -    var fakeBody = {append: function(node){scripts.push(node);}}; +    var fakeBody = [{appendChild: function(node){scripts.push(node);}, +                     removeChild: function(node){removedScripts.push(node);}}];      var FakeXhr = function(){        xhr = this; @@ -87,15 +89,13 @@ describe('browser', function(){          expect(callback).not.toHaveBeenCalled();          expect(scripts.length).toEqual(1);          var script = scripts[0]; -        script.remove = function(){ -          log += 'remove();'; -        }; -        var url = script.attr('src').split('?cb='); +        var url = script.src.split('?cb=');          expect(url[0]).toEqual('http://example.org/path');          expect(typeof fakeWindow[url[1]]).toEqual($function);          fakeWindow[url[1]]('data');          expect(callback).toHaveBeenCalled(); -        expect(log).toEqual('remove();200:data;'); +        expect(log).toEqual('200:data;'); +        expect(scripts).toEqual(removedScripts);          expect(fakeWindow[url[1]]).toBeUndefined();        });      });  | 
