mirror of
https://github.com/tenrok/axios.git
synced 2026-06-05 16:42:32 +03:00
feat: export getAdapter function (#5324)
This commit is contained in:
@@ -16,6 +16,7 @@ import axios, {
|
||||
ParamsSerializerOptions,
|
||||
toFormData,
|
||||
formToJSON,
|
||||
getAdapter,
|
||||
all,
|
||||
isCancel,
|
||||
isAxiosError,
|
||||
@@ -570,6 +571,33 @@ axios.get('/user', {
|
||||
adapter: ['xhr', 'http']
|
||||
});
|
||||
|
||||
|
||||
{
|
||||
// getAdapter
|
||||
|
||||
getAdapter(axios.create().defaults.adapter);
|
||||
getAdapter(undefined);
|
||||
getAdapter([]);
|
||||
getAdapter(['xhr']);
|
||||
getAdapter([adapter]);
|
||||
getAdapter(['xhr', 'http']);
|
||||
getAdapter([adapter, 'xhr']);
|
||||
getAdapter([adapter, adapter]);
|
||||
getAdapter('xhr');
|
||||
getAdapter(adapter);
|
||||
const _: AxiosAdapter = getAdapter('xhr');
|
||||
const __: AxiosAdapter = getAdapter(['xhr']);
|
||||
|
||||
// @ts-expect-error
|
||||
getAdapter();
|
||||
// @ts-expect-error
|
||||
getAdapter(123);
|
||||
// @ts-expect-error
|
||||
getAdapter([123]);
|
||||
// @ts-expect-error
|
||||
getAdapter('xhr', 'http');
|
||||
}
|
||||
|
||||
// AxiosHeaders
|
||||
|
||||
// iterator
|
||||
|
||||
@@ -54,6 +54,10 @@ describe('static api', function () {
|
||||
it('should have mergeConfig properties', function () {
|
||||
expect(typeof axios.mergeConfig).toEqual('function');
|
||||
});
|
||||
|
||||
it('should have getAdapter properties', function () {
|
||||
expect(typeof axios.getAdapter).toEqual('function');
|
||||
});
|
||||
});
|
||||
|
||||
describe('instance api', function () {
|
||||
|
||||
@@ -24,6 +24,7 @@ describe('instance', function () {
|
||||
'getUri',
|
||||
'isAxiosError',
|
||||
'mergeConfig',
|
||||
'getAdapter',
|
||||
'VERSION',
|
||||
'default',
|
||||
'toFormData',
|
||||
|
||||
Reference in New Issue
Block a user