From 0f73084e9d21cea99f0535e6ca30a1341b7047dc Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 19 May 2010 11:51:17 -0700 Subject: added error handler to xhr requests --- test/ResourceSpec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/ResourceSpec.js') diff --git a/test/ResourceSpec.js b/test/ResourceSpec.js index d2d52d47..2f285bcf 100644 --- a/test/ResourceSpec.js +++ b/test/ResourceSpec.js @@ -138,4 +138,19 @@ describe("resource", function() { expect(person.name).toEqual('misko'); }); + describe('failure mode', function(){ + it('should report error when non 200', function(){ + xhr.expectGET('/CreditCard/123').respond(500, "Server Error"); + var cc = CreditCard.get({id:123}); + try { + xhr.flush(); + fail('expected exception, non thrown'); + } catch (e) { + expect(e.status).toEqual(500); + expect(e.response).toEqual('Server Error'); + expect(e.message).toEqual('500: Server Error'); + } + }); + }); + }); -- cgit v1.2.3