2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +03:00

Interceptor clear (#4248)

* Adding interceptor clearing

* Fixing spacing

* changed clear to empty array

* fixed interceptor clear test

Co-authored-by: Andrew <Andrew@Andrews-MacBook-Pro.local>
Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Landro3
2022-05-05 15:31:06 -04:00
committed by GitHub
parent 743b4a8b8f
commit 544cf134f3
3 changed files with 46 additions and 0 deletions
+28
View File
@@ -571,4 +571,32 @@ describe('interceptors', function () {
done();
});
});
it('should clear all request interceptors', function () {
var instance = axios.create({
baseURL: 'http://test.com/'
});
instance.interceptors.request.use(function (config) {
return config
});
instance.interceptors.request.clear();
expect(instance.interceptors.request.handlers.length).toBe(0);
});
it('should clear all response interceptors', function () {
var instance = axios.create({
baseURL: 'http://test.com/'
});
instance.interceptors.response.use(function (config) {
return config
});
instance.interceptors.response.clear();
expect(instance.interceptors.response.handlers.length).toBe(0);
});
});