()
| 280 | // ============================================================================= |
| 281 | |
| 282 | async function testSignalAsync() { |
| 283 | async function* gen() { |
| 284 | for (let i = 0; ; i++) { |
| 285 | yield [Buffer.from(`chunk${i}`)]; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | const ac = new AbortController(); |
| 290 | const readable = toReadable(gen(), { signal: ac.signal }); |
| 291 | |
| 292 | const chunks = []; |
| 293 | await assert.rejects(async () => { |
| 294 | for await (const chunk of readable) { |
| 295 | chunks.push(chunk); |
| 296 | if (chunks.length >= 3) { |
| 297 | ac.abort(); |
| 298 | } |
| 299 | } |
| 300 | }, { name: 'AbortError' }); |
| 301 | assert.ok(chunks.length >= 3); |
| 302 | assert.ok(readable.destroyed); |
| 303 | } |
| 304 | |
| 305 | // ============================================================================= |
| 306 | // fromStreamIter: signal already aborted |
no test coverage detected