diff options
| author | Misko Hevery | 2011-03-09 21:12:40 -0800 | 
|---|---|---|
| committer | Misko Hevery | 2011-03-11 14:16:52 -0800 | 
| commit | 5343deb3da0e667599fe66d8efa3566b4e337a24 (patch) | |
| tree | a375202db226a47beda6bfad4b6ee5096a1171e1 /test/service/xhrSpec.js | |
| parent | 26bad2bf878e54fa78ff26518d1275a7e0b5b39c (diff) | |
| download | angular.js-5343deb3da0e667599fe66d8efa3566b4e337a24.tar.bz2 | |
Consider all 2xx responses as OK, not just 200
Diffstat (limited to 'test/service/xhrSpec.js')
| -rw-r--r-- | test/service/xhrSpec.js | 26 | 
1 files changed, 22 insertions, 4 deletions
| diff --git a/test/service/xhrSpec.js b/test/service/xhrSpec.js index fc51eff2..66dbe94d 100644 --- a/test/service/xhrSpec.js +++ b/test/service/xhrSpec.js @@ -2,7 +2,9 @@ describe('$xhr', function() {    var scope, $browser, $browserXhr, $log, $xhr, log;    beforeEach(function(){ -    scope = angular.scope({}, angular.service, { '$log': $log = {} }); +    scope = angular.scope({}, angular.service, { '$log': $log = { +        error: dump +    } });      $browser = scope.$service('$browser');      $browserXhr = $browser.xhr;      $xhr = scope.$service('$xhr'); @@ -16,8 +18,7 @@ describe('$xhr', function() {    function callback(code, response) { -    expect(code).toEqual(200); -    log = log + toJson(response) + ';'; +    log = log + '{code=' + code + '; response=' + toJson(response) + '}';    } @@ -32,7 +33,24 @@ describe('$xhr', function() {      $browserXhr.flush(); -    expect(log).toEqual('"third";["second"];"first";'); +    expect(log).toEqual( +        '{code=200; response="third"}' + +        '{code=200; response=["second"]}' + +        '{code=200; response="first"}'); +  }); + +  it('should allow all 2xx requests', function(){ +    $browserXhr.expectGET('/req1').respond(200, '1'); +    $xhr('GET', '/req1', null, callback); +    $browserXhr.flush(); + +    $browserXhr.expectGET('/req2').respond(299, '2'); +    $xhr('GET', '/req2', null, callback); +    $browserXhr.flush(); + +    expect(log).toEqual( +        '{code=200; response="1"}' + +        '{code=299; response="2"}');    }); | 
