diff options
| author | Misko Hevery | 2010-07-22 11:18:32 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-07-22 11:18:32 -0700 |
| commit | 849a05b5a578f19ddc3d24dc9fbd304e0e07612a (patch) | |
| tree | 3e32e2ab7b8c1ed3f53e5b568990070b5edab4fa /test/BrowserSpecs.js | |
| parent | b5bbfaeb80c3f89c65d14c72cff6f0e1c8aa497a (diff) | |
| download | angular.js-849a05b5a578f19ddc3d24dc9fbd304e0e07612a.tar.bz2 | |
added jsonp to resources
Diffstat (limited to 'test/BrowserSpecs.js')
| -rw-r--r-- | test/BrowserSpecs.js | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/test/BrowserSpecs.js b/test/BrowserSpecs.js index 3ce158b4..a9f61a6b 100644 --- a/test/BrowserSpecs.js +++ b/test/BrowserSpecs.js @@ -1,10 +1,15 @@ describe('browser', function(){ - var browser, location; + var browser, location, head; beforeEach(function(){ location = {href:"http://server", hash:""}; - browser = new Browser(location, {}); + document = jqLite(window.document); + head = { + scripts: [], + append: function(node){head.scripts.push(node);} + }; + browser = new Browser(location, jqLite(window.document), head); browser.setTimeout = noop; }); @@ -45,4 +50,23 @@ describe('browser', function(){ }); }); + describe('xhr', function(){ + describe('JSON', function(){ + it('should add script tag for request', function() { + var log = ""; + browser.xhr('JSON', 'http://example.org/path?cb=JSON_CALLBACK', function(code, data){ + log += code + ':' + data + ';'; + }); + expect(head.scripts.length).toEqual(1); + var url = head.scripts[0].src.split('?cb='); + expect(url[0]).toEqual('http://example.org/path'); + expect(typeof window[url[1]]).toEqual('function'); + window[url[1]]('data'); + expect(log).toEqual('200:data;'); + expect(typeof window[url[1]]).toEqual('undefined'); + + }); + }); + }); + }); |
