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

Refactored AxiosError to a constructor;

Refactored `Cancel` to a constructor, a subclass of the `AxiosError`;
Expose CanceledError class;
Refactored axios error codes;
Added `toFlatObject` util;
This commit is contained in:
DigitalBrainJS
2021-10-14 18:53:46 +03:00
parent 1025d1231a
commit 7f1236652a
29 changed files with 332 additions and 221 deletions
+7 -8
View File
@@ -1,19 +1,18 @@
var createError = require('../../../lib/core/createError');
var enhanceError = require('../../../lib/core/enhanceError');
var AxiosError = require('../../../lib/core/AxiosError');
var isAxiosError = require('../../../lib/helpers/isAxiosError');
describe('helpers::isAxiosError', function () {
it('should return true if the error is created by core::createError', function () {
expect(isAxiosError(createError('Boom!', { foo: 'bar' })))
describe('helpers::isAxiosError', function() {
it('should return true if the error is created by core::createError', function() {
expect(isAxiosError(new AxiosError('Boom!', null, { foo: 'bar' })))
.toBe(true);
});
it('should return true if the error is enhanced by core::enhanceError', function () {
expect(isAxiosError(enhanceError(new Error('Boom!'), { foo: 'bar' })))
it('should return true if the error is enhanced by core::enhanceError', function() {
expect(isAxiosError(AxiosError.from(new Error('Boom!'), null, { foo: 'bar' })))
.toBe(true);
});
it('should return false if the error is a normal Error instance', function () {
it('should return false if the error is a normal Error instance', function() {
expect(isAxiosError(new Error('Boom!')))
.toBe(false);
});