mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
ef3711d1b3
* 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>
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
import assert from 'assert';
|
|
import composeSignals from '../../../lib/helpers/composeSignals.js';
|
|
|
|
describe('helpers::composeSignals', () => {
|
|
before(function () {
|
|
if (typeof AbortController !== 'function') {
|
|
this.skip();
|
|
}
|
|
});
|
|
|
|
it('should abort when any of the signals abort', () => {
|
|
let called;
|
|
|
|
const controllerA = new AbortController();
|
|
const controllerB = new AbortController();
|
|
|
|
const signal = composeSignals([controllerA.signal, controllerB.signal]);
|
|
|
|
signal.addEventListener('abort', () => {
|
|
called = true;
|
|
});
|
|
|
|
controllerA.abort(new Error('test'));
|
|
|
|
assert.ok(called);
|
|
});
|
|
|
|
it('should abort on timeout', async () => {
|
|
const signal = composeSignals([], 100);
|
|
|
|
await new Promise((resolve) => {
|
|
signal.addEventListener('abort', resolve);
|
|
});
|
|
|
|
assert.match(String(signal.reason), /timeout of 100ms exceeded/);
|
|
});
|
|
|
|
it('should return undefined if signals and timeout are not provided', async () => {
|
|
const signal = composeSignals([]);
|
|
|
|
assert.strictEqual(signal, undefined);
|
|
});
|
|
});
|