diff options
| author | Karl Seamon | 2011-07-29 18:32:30 -0400 |
|---|---|---|
| committer | Igor Minar | 2011-08-19 01:20:45 -0700 |
| commit | 4ec1d8ee86e3138fb91543ca0dca28463895c090 (patch) | |
| tree | 9f7fff13f177317ff15f8804789a44576a151908 /test/BrowserSpecs.js | |
| parent | c37bfde9eb31556ee1eb146795b0c1f1504a4a26 (diff) | |
| download | angular.js-4ec1d8ee86e3138fb91543ca0dca28463895c090.tar.bz2 | |
feat($xhr,$resource): expose response headers in callbacks
all $xhr*, $resource and related mocks now have access to headers from
their callbacks
Diffstat (limited to 'test/BrowserSpecs.js')
| -rw-r--r-- | test/BrowserSpecs.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/BrowserSpecs.js b/test/BrowserSpecs.js index 92e4e501..93882c1a 100644 --- a/test/BrowserSpecs.js +++ b/test/BrowserSpecs.js @@ -49,6 +49,13 @@ describe('browser', function(){ this.send = function(post){ xhr.post = post; }; + this.getResponseHeader = function(header) { + return header; + }; + this.getAllResponseHeaders = function() { + return 'Content-Type: application/json\n\rContent-Encoding: gzip\n\rContent-Type: text/json'; + } + }; logs = {log:[], warn:[], info:[], error:[]}; @@ -198,6 +205,41 @@ describe('browser', function(){ expect(code).toEqual(202); expect(response).toEqual('RESPONSE'); }); + + describe('response headers', function() { + it('should return a single response header', function() { + var headerA; + + browser.xhr('GET', 'URL', null, function(code, resp, headers) { + headerA = headers('A-Header'); + }); + + xhr.status = 200; + xhr.responseText = 'RESPONSE'; + xhr.readyState = 4; + xhr.onreadystatechange(); + + expect(headerA).toEqual('a-header'); + }); + + it('should return an object containing all response headers', function() { + var allHeaders; + + browser.xhr('GET', 'URL', null, function(code, resp, headers) { + allHeaders = headers(); + }); + + xhr.status = 200; + xhr.responseText = 'RESPONSE'; + xhr.readyState = 4; + xhr.onreadystatechange(); + + expect(allHeaders).toEqual({ + 'content-type': 'application/json, text/json', + 'content-encoding': 'gzip' + }); + }); + }); }); describe('defer', function() { |
