mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
fix(headers): fixed support for setting multiple header values from an iterated source; (#6885)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import AxiosHeaders from '../../../lib/core/AxiosHeaders.js';
|
||||
import assert from 'assert';
|
||||
|
||||
const [nodeMajorVersion] = process.versions.node.split('.').map(v => parseInt(v, 10));
|
||||
|
||||
describe('AxiosHeaders', function () {
|
||||
it('should support headers argument', function () {
|
||||
@@ -82,6 +83,27 @@ describe('AxiosHeaders', function () {
|
||||
|
||||
assert.strictEqual(headers.get('x'), '123');
|
||||
});
|
||||
|
||||
it('should support setting multiple header values from an iterable source', function () {
|
||||
if (nodeMajorVersion < 18) {
|
||||
this.skip();
|
||||
return;
|
||||
}
|
||||
|
||||
const headers = new AxiosHeaders();
|
||||
|
||||
const nativeHeaders = new Headers();
|
||||
|
||||
nativeHeaders.append('set-cookie', 'foo');
|
||||
nativeHeaders.append('set-cookie', 'bar');
|
||||
nativeHeaders.append('set-cookie', 'baz');
|
||||
nativeHeaders.append('y', 'qux');
|
||||
|
||||
headers.set(nativeHeaders);
|
||||
|
||||
assert.deepStrictEqual(headers.get('set-cookie'), ['foo', 'bar', 'baz']);
|
||||
assert.strictEqual(headers.get('y'), 'qux');
|
||||
});
|
||||
});
|
||||
|
||||
it('should support uppercase name mapping for names overlapped by class methods', () => {
|
||||
|
||||
Reference in New Issue
Block a user