Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

test($http): ensure json deserialization errors are forwarded to erro… #15689

Merged
merged 1 commit into from
Feb 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions test/ng/httpSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});

});


Expand Down