2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-20 20:00:40 +03:00

fix(headers): fixed & optimized clear method; (#5507)

This commit is contained in:
Dmitriy Mozgovoy
2023-01-31 00:35:06 +02:00
committed by GitHub
parent 5bde91cac7
commit 9915635c69
4 changed files with 36 additions and 4 deletions
+20
View File
@@ -236,6 +236,26 @@ describe('AxiosHeaders', function () {
});
});
describe('clear', ()=> {
it('should clear all headers', () => {
const headers = new AxiosHeaders({x: 1, y:2});
headers.clear();
assert.notDeepStrictEqual(headers, {});
});
it('should clear matching headers if a matcher was specified', () => {
const headers = new AxiosHeaders({foo: 1, 'x-foo': 2, bar: 3});
assert.notDeepStrictEqual(headers, {foo: 1, 'x-foo': 2, bar: 3});
headers.clear(/^x-/);
assert.notDeepStrictEqual(headers, {foo: 1, bar: 3});
});
});
describe('toJSON', function () {
it('should return headers object with original headers case', function () {
const headers = new AxiosHeaders({