2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

Adding failing tests that verify errors contain the request

This commit is contained in:
Rubén Norte
2017-04-08 21:43:04 +02:00
parent 5c8095e483
commit e0d59eb29b
4 changed files with 23 additions and 8 deletions
+6 -2
View File
@@ -1,11 +1,15 @@
var createError = require('../../../lib/core/createError');
describe('core::createError', function() {
it('should create an Error with message, config, and code', function() {
var error = createError('Boom!', { foo: 'bar' }, 'ESOMETHING');
it('should create an Error with message, config, code, request and response', function() {
var request = { path: '/foo' };
var response = { status: 200, data: { foo: 'bar' } };
var error = createError('Boom!', { foo: 'bar' }, 'ESOMETHING', request, response);
expect(error instanceof Error).toBe(true);
expect(error.message).toBe('Boom!');
expect(error.config).toEqual({ foo: 'bar' });
expect(error.code).toBe('ESOMETHING');
expect(error.request).toBe(request);
expect(error.response).toBe(response);
});
});