2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +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:
Xianming Zhong
2020-06-09 02:52:45 +08:00
committed by GitHub
parent 487941663b
commit 0d69a79c81
10 changed files with 413 additions and 154 deletions
+42
View File
@@ -177,6 +177,48 @@ describe('requests', function () {
});
});
it('should resolve when validateStatus is null', function (done) {
var resolveSpy = jasmine.createSpy('resolve');
var rejectSpy = jasmine.createSpy('reject');
axios('/foo', {
validateStatus: null
}).then(resolveSpy)
.catch(rejectSpy)
.then(function () {
expect(resolveSpy).toHaveBeenCalled();
expect(rejectSpy).not.toHaveBeenCalled();
done();
});
getAjaxRequest().then(function (request) {
request.respondWith({
status: 500
});
});
});
it('should resolve when validateStatus is undefined', function (done) {
var resolveSpy = jasmine.createSpy('resolve');
var rejectSpy = jasmine.createSpy('reject');
axios('/foo', {
validateStatus: undefined
}).then(resolveSpy)
.catch(rejectSpy)
.then(function () {
expect(resolveSpy).toHaveBeenCalled();
expect(rejectSpy).not.toHaveBeenCalled();
done();
});
getAjaxRequest().then(function (request) {
request.respondWith({
status: 500
});
});
});
// https://github.com/axios/axios/issues/378
it('should return JSON when rejecting', function (done) {
var response;