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:
@@ -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();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user