2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00
Files
axios/tests/unit/adapters/adapters.test.js
T
Jay fa337332b9 Update unit testing flows as part of migration to vitest (#7484)
* chore: small fixes to tests

* feat: transitional move to vitests

* feat: moving unit tests in progress

* feat: moving more unit tests over

* feat: more tests moved

* feat: updated more sections of the http test

* chore: wip http tests

* chore: wip http tests

* chore: more http tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: tests

* chore: remove un-needed docs

* chore: update package lock

* chore: update lock
2026-03-06 20:42:14 +02:00

49 lines
1.4 KiB
JavaScript

import { beforeEach, describe, it } from 'vitest';
import assert from 'assert';
import adapters from '../../../lib/adapters/adapters.js';
describe('adapters', () => {
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', () => {
const adapter = () => {};
assert.strictEqual(adapters.getAdapter(adapter), adapter);
});
it('should support loading by name', () => {
const adapter = () => {};
adapters.adapters.testadapter = adapter;
assert.strictEqual(adapters.getAdapter('testAdapter'), adapter);
});
it('should detect adapter unavailable status', () => {
adapters.adapters.testadapter = null;
assert.throws(() => adapters.getAdapter('testAdapter'), /is not available in the build/);
});
it('should detect adapter unsupported status', () => {
adapters.adapters.testadapter = false;
assert.throws(() => adapters.getAdapter('testAdapter'), /is not supported by the environment/);
});
it('should pick suitable adapter from the list', () => {
const adapter = () => {};
Object.assign(adapters.adapters, {
foo: false,
bar: null,
baz: adapter,
});
assert.strictEqual(adapters.getAdapter(['foo', 'bar', 'baz']), adapter);
});
});