diff options
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"}'); }); |
