2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-05 16:42:32 +03:00

fix: issues with version 1.13.3 (#7352)

This commit is contained in:
Jay
2026-01-27 08:04:06 +02:00
committed by GitHub
parent af4f6d960f
commit ee90dfc28a
5 changed files with 27 additions and 107 deletions
-73
View File
@@ -599,77 +599,4 @@ describe('interceptors', function () {
expect(instance.interceptors.response.handlers.length).toBe(0);
});
it('should handler the error in the same request interceptors', function (done) {
const rejectedSpy1 = jasmine.createSpy('rejectedSpy1');
const rejectedSpy2 = jasmine.createSpy('rejectedSpy2');
const error1 = new Error('deadly error 1');
const error2 = new Error('deadly error 2');
axios.interceptors.request.use(function () {
throw error1;
}, rejectedSpy1);
axios.interceptors.request.use(function () {
throw error2;
}, rejectedSpy2);
axios('/foo').catch();
getAjaxRequest().then(function () {
expect(rejectedSpy1).toHaveBeenCalledWith(error1);
expect(rejectedSpy2).toHaveBeenCalledWith(error2);
done();
});
});
it('should handle the error in the same response interceptors', function (done) {
const rejectedSpy1 = jasmine.createSpy('rejectedSpy1');
const rejectedSpy2 = jasmine.createSpy('rejectedSpy2');
const error1 = new Error('deadly error 1');
const error2 = new Error('deadly error 2');
axios.interceptors.response.use(function () {
throw error1;
}, rejectedSpy1);
axios.interceptors.response.use(function () {
throw error2;
}, rejectedSpy2);
axios('/foo');
getAjaxRequest().then(function (request) {
request.respondWith({
status: 200,
responseText: 'OK'
});
setTimeout(function () {
expect(rejectedSpy1).toHaveBeenCalledWith(error1);
expect(rejectedSpy2).toHaveBeenCalledWith(error2);
done();
}, 100);
});
});
it('should skip the modification of config in the interceptors throwing error', function (done) {
const rejectedSpy = jasmine.createSpy('rejectedSpy');
const error = new Error('deadly error');
axios.interceptors.request.use(function (config) {
config.headers.test = 'added by interceptor';
return config;
});
axios.interceptors.request.use(function () {
throw error;
}, rejectedSpy);
axios('/foo').catch();
getAjaxRequest().then(function (request) {
expect(rejectedSpy).toHaveBeenCalledWith(error);
expect(request.requestHeaders.test).toBe('added by interceptor');
done();
});
});
});