2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00
Files
axios/test/unit/adapters/adapters.js
T
Jay ef3711d1b3 feat: implement prettier and fix all issues (#7385)
* feat: implement prettier and fix all issues

* fix: failing tests

* fix: implement feedback from codel, ai etc

* chore: dont throw in trim function

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

* fix: incorrect fix

---------

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2026-02-14 16:59:48 +02:00

48 lines
1.4 KiB
JavaScript

import adapters from '../../../lib/adapters/adapters.js';
import assert from 'assert';
describe('adapters', function () {
const store = { ...adapters.adapters };
beforeEach(() => {
Object.keys(adapters.adapters).forEach((name) => {
delete adapters.adapters[name];
});
Object.assign(adapters.adapters, store);
});
it('should support loading by fn handle', function () {
const adapter = () => {};
assert.strictEqual(adapters.getAdapter(adapter), adapter);
});
it('should support loading by name', function () {
const adapter = () => {};
adapters.adapters['testadapter'] = adapter;
assert.strictEqual(adapters.getAdapter('testAdapter'), adapter);
});
it('should detect adapter unavailable status', function () {
adapters.adapters['testadapter'] = null;
assert.throws(() => adapters.getAdapter('testAdapter'), /is not available in the build/);
});
it('should detect adapter unsupported status', function () {
adapters.adapters['testadapter'] = false;
assert.throws(() => adapters.getAdapter('testAdapter'), /is not supported by the environment/);
});
it('should pick suitable adapter from the list', function () {
const adapter = () => {};
Object.assign(adapters.adapters, {
foo: false,
bar: null,
baz: adapter,
});
assert.strictEqual(adapters.getAdapter(['foo', 'bar', 'baz']), adapter);
});
});