diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index ae0137943758..1318a742125a 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -1368,6 +1368,20 @@ describe('$http', function() { expect(callback.calls.argsFor(1)[0].data).toEqual('{"is": "not"} ["json"]'); } ); + + it('should forward json deserialization errors to the http error handler', + function() { + var errCallback = jasmine.createSpy('error'); + + $httpBackend.expect('GET', '/url').respond('abcd', {'Content-Type': 'application/json'}); + $http({method: 'GET', url: '/url'}).then(callback).catch(errCallback); + $httpBackend.flush(); + + expect(callback).not.toHaveBeenCalled(); + expect(errCallback).toHaveBeenCalledOnce(); + expect(errCallback.calls.mostRecent().args[0]).toEqual(jasmine.any(SyntaxError)); + }); + });