mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +03:00
Refactor mergeConfig without utils.deepMerge (#2844)
* Adding failing test * Fixing #2587 default custom config persisting * Adding Concat keys and filter duplicates * Fixed value from CPE * update for review feedbacks * no deepMerge * only merge between plain objects * fix rename * always merge config by mergeConfig * extract function mergeDeepProperties * refactor mergeConfig with all keys, and add special logic for validateStatus * add test for resetting headers * add lots of tests and fix a bug * should not inherit `data` * use simple toString * revert #1845 Co-authored-by: David Tanner <david.tanner@lifeomic.com> Co-authored-by: Justin Beckwith <justin.beckwith@gmail.com>
This commit is contained in:
+26
-15
@@ -42,21 +42,6 @@ describe('headers', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not set header if value is null', function (done) {
|
||||
expect(axios.defaults.headers.common['Accept']).toEqual('application/json, text/plain, */*');
|
||||
|
||||
axios('/foo', {
|
||||
headers: {
|
||||
Accept: null
|
||||
}
|
||||
});
|
||||
|
||||
getAjaxRequest().then(function (request) {
|
||||
expect(typeof request.requestHeaders['Accept']).toEqual('undefined');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should add extra headers for post', function (done) {
|
||||
var headers = axios.defaults.headers.common;
|
||||
|
||||
@@ -72,6 +57,32 @@ describe('headers', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should reset headers by null or explicit undefined', function (done) {
|
||||
axios.create({
|
||||
headers: {
|
||||
common: {
|
||||
'x-header-a': 'a',
|
||||
'x-header-b': 'b',
|
||||
'x-header-c': 'c'
|
||||
}
|
||||
}
|
||||
}).post('/foo', {fizz: 'buzz'}, {
|
||||
headers: {
|
||||
'Content-Type': null,
|
||||
'x-header-a': null,
|
||||
'x-header-b': undefined
|
||||
}
|
||||
});
|
||||
|
||||
getAjaxRequest().then(function (request) {
|
||||
testHeaderValue(request.requestHeaders, 'Content-Type', null);
|
||||
testHeaderValue(request.requestHeaders, 'x-header-a', null);
|
||||
testHeaderValue(request.requestHeaders, 'x-header-b', undefined);
|
||||
testHeaderValue(request.requestHeaders, 'x-header-c', 'c');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should use application/json when posting an object', function (done) {
|
||||
axios.post('/foo/bar', {
|
||||
firstName: 'foo',
|
||||
|
||||
Reference in New Issue
Block a user