Open
Description
The first test times out and the second passes:
import { PassThrough } from 'stream';
import { source as makeSourceAbortable } from 'abortable-iterator';
test('Empty source', async () => {
const source = new PassThrough();
const abortController = new AbortController();
const abortableSource = makeSourceAbortable(source, abortController.signal, {
returnOnAbort: true,
});
setImmediate(() => abortController.abort());
for await (const chunk of abortableSource) {
throw new Error(`Shouldn't have got ${chunk}`);
}
});
test('Non-empty source', async () => {
const source = new PassThrough();
const abortController = new AbortController();
const abortableSource = makeSourceAbortable(source, abortController.signal, {
returnOnAbort: true,
});
setImmediate(() => {
source.write('foo');
abortController.abort();
});
for await (const chunk of abortableSource) {
expect(chunk).toBe('foo');
}
});
Metadata
Metadata
Assignees
Labels
No labels