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

Fix tests in browsers (#2748)

This commit is contained in:
Xianming Zhong
2020-02-15 15:54:43 +08:00
committed by GitHub
parent 56b72bbd2c
commit 2034c1db7e
+23 -14
View File
@@ -40,24 +40,33 @@ describe('core::mergeConfig', function() {
expect(merged.data).toEqual(undefined); expect(merged.data).toEqual(undefined);
}); });
['auth', 'headers', 'params', 'proxy'].forEach(key => { ['auth', 'headers', 'params', 'proxy'].forEach(function(key) {
it(`should set new config for ${key} without default`, function() { it('should set new config for' + key + ' without default', function() {
expect(mergeConfig({ [key]: undefined }, { [key]: { user: 'foo', pass: 'test' } })).toEqual({ var a = {}, b = {}, c = {}
[key]: { user: 'foo', pass: 'test' } a[key] = undefined
}); b[key] = { user: 'foo', pass: 'test' }
c[key] = { user: 'foo', pass: 'test' }
expect(mergeConfig(a, b)).toEqual(c);
}); });
it(`should merge ${key} with defaults`, function() { it('should merge ' + key + ' with defaults', function() {
expect(mergeConfig({ [key]: { user: 'foo', pass: 'bar' } }, { [key]: { pass: 'test' } })).toEqual({ var a = {}, b = {}, c = {};
[key]: { user: 'foo', pass: 'test' } a[key] = { user: 'foo', pass: 'bar' };
}); b[key] = { pass: 'test' };
c[key] = { user: 'foo', pass: 'test' };
expect(mergeConfig(a, b)).toEqual(c);
}); });
it(`should overwrite default ${key} with a non-object value`, function() { it('should overwrite default ' + key + ' with a non-object value', function() {
[false, null, 123].forEach(value => { [false, null, 123].forEach(function(value) {
expect(mergeConfig({ [key]: { user: 'foo', pass: 'test' } }, { [key]: value })).toEqual({ var a = {}, b = {}, c = {};
[key]: value a[key] = { user: 'foo', pass: 'test' };
}); b[key] = value;
c[key] = value;
expect(mergeConfig(a, b)).toEqual(c);
}); });
}); });
}); });