2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-20 20:00:40 +03:00

Improve error handling

This commit is contained in:
Nick Uraltsev
2016-06-13 13:56:08 -07:00
parent 120e8f5557
commit 91dae3c4ad
14 changed files with 120 additions and 41 deletions
+11
View File
@@ -46,6 +46,10 @@ describe('requests', function () {
var finish = function () {
expect(resolveSpy).not.toHaveBeenCalled();
expect(rejectSpy).toHaveBeenCalled();
var reason = rejectSpy.calls.first().args[0];
expect(reason instanceof Error).toBe(true);
expect(reason.config.method).toBe('get');
expect(reason.config.url).toBe('http://thisisnotaserver');
done();
};
@@ -68,6 +72,13 @@ describe('requests', function () {
.then(function () {
expect(resolveSpy).not.toHaveBeenCalled();
expect(rejectSpy).toHaveBeenCalled();
var reason = rejectSpy.calls.first().args[0];
expect(reason instanceof Error).toBe(true);
expect(reason.message).toBe('Request failed with status code 500');
expect(reason.config.method).toBe('get');
expect(reason.config.url).toBe('/foo');
expect(reason.response.status).toBe(500);
done();
});