diff options
| author | Karl Seamon | 2011-08-18 15:07:04 -0400 |
|---|---|---|
| committer | Karl Seamon | 2011-08-18 15:07:04 -0400 |
| commit | 6114c8f504e99fecb0d62cce4beb3a8f39f301ec (patch) | |
| tree | 6e8567b0a64ed3f2e1569d184617985042744760 /test/ResourceSpec.js | |
| parent | b99b0a80723ad3a9b43e9ef36869f521eaec19ec (diff) | |
| download | angular.js-6114c8f504e99fecb0d62cce4beb3a8f39f301ec.tar.bz2 | |
fix($resource): properly call error callback when resource is called with two arguments
Diffstat (limited to 'test/ResourceSpec.js')
| -rw-r--r-- | test/ResourceSpec.js | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/test/ResourceSpec.js b/test/ResourceSpec.js index e2f14682..c289ae89 100644 --- a/test/ResourceSpec.js +++ b/test/ResourceSpec.js @@ -244,22 +244,35 @@ describe("resource", function() { describe('failure mode', function() { var ERROR_CODE = 500, - ERROR_RESPONSE = 'Server Error'; + ERROR_RESPONSE = 'Server Error', + errorCB; beforeEach(function() { - xhr.expectGET('/CreditCard/123').respond(ERROR_CODE, ERROR_RESPONSE); + errorCB = jasmine.createSpy(); }); it('should report error when non 2xx if error callback is not provided', function() { + xhr.expectGET('/CreditCard/123').respond(ERROR_CODE, ERROR_RESPONSE); CreditCard.get({id:123}); xhr.flush(); expect($xhrErr).toHaveBeenCalled(); }); it('should call the error callback if provided on non 2xx response', function() { - CreditCard.get({id:123}, noop, callback); + xhr.expectGET('/CreditCard/123').respond(ERROR_CODE, ERROR_RESPONSE); + CreditCard.get({id:123}, callback, errorCB); + xhr.flush(); + expect(errorCB).toHaveBeenCalledWith(500, ERROR_RESPONSE); + expect(callback).not.toHaveBeenCalled(); + expect($xhrErr).not.toHaveBeenCalled(); + }); + + it('should call the error callback if provided on non 2xx response', function() { + xhr.expectGET('/CreditCard').respond(ERROR_CODE, ERROR_RESPONSE); + CreditCard.get(callback, errorCB); xhr.flush(); - expect(callback).toHaveBeenCalledWith(500, ERROR_RESPONSE); + expect(errorCB).toHaveBeenCalledWith(500, ERROR_RESPONSE); + expect(callback).not.toHaveBeenCalled(); expect($xhrErr).not.toHaveBeenCalled(); }); }); |
