diff options
| author | Igor Minar | 2011-02-15 01:12:45 -0500 | 
|---|---|---|
| committer | Igor Minar | 2011-02-15 11:01:53 -0500 | 
| commit | 1777110958f76ee4be5760e36c96702223385918 (patch) | |
| tree | 5aa03b246507e66877e5eac69e58e004e244d7a5 /test/service/xhr.errorSpec.js | |
| parent | d2089a16335276eecb8d81eb17332c2dff2cf1a2 (diff) | |
| download | angular.js-1777110958f76ee4be5760e36c96702223385918.tar.bz2 | |
split up services into individual files
- split up services into files under src/service
- split up specs into files under test/service
- rewrite all specs so that they don't depend on one global forEach
- get rid of obsolete code and tests in ng:switch
- rename mock $log spec from "$log" to "$log mock"
Diffstat (limited to 'test/service/xhr.errorSpec.js')
| -rw-r--r-- | test/service/xhr.errorSpec.js | 36 | 
1 files changed, 36 insertions, 0 deletions
| diff --git a/test/service/xhr.errorSpec.js b/test/service/xhr.errorSpec.js new file mode 100644 index 00000000..da1b102e --- /dev/null +++ b/test/service/xhr.errorSpec.js @@ -0,0 +1,36 @@ +describe('$xhr.error', function() { +  var scope, $browser, $browserXhr, $xhr, $xhrError, log; + +  beforeEach(function(){ +    scope = angular.scope({}, angular.service, { +      '$xhr.error': $xhrError = jasmine.createSpy('$xhr.error') +    }); +    $browser = scope.$service('$browser'); +    $browserXhr = $browser.xhr; +    $xhr = scope.$service('$xhr'); +    log = ''; +  }); + + +  afterEach(function(){ +    dealoc(scope); +  }); + + +  function callback(code, response) { +    expect(code).toEqual(200); +    log = log + toJson(response) + ';'; +  } + + +  it('should handle non 200 status codes by forwarding to error handler', function(){ +    $browserXhr.expectPOST('/req', 'MyData').respond(500, 'MyError'); +    $xhr('POST', '/req', 'MyData', callback); +    $browserXhr.flush(); +    var cb = $xhrError.mostRecentCall.args[0].callback; +    expect(typeof cb).toEqual($function); +    expect($xhrError).wasCalledWith( +        {url:'/req', method:'POST', data:'MyData', callback:cb}, +        {status:500, body:'MyError'}); +  }); +}); | 
