Skip to content

Commit 22ac227

Browse files
Lxxyxtargos
authored andcommitted
1 parent d38a0ec commit 22ac227

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

Diff for: test/parallel/test-readable-from.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
const { mustCall } = require('../common');
44
const { once } = require('events');
55
const { Readable } = require('stream');
6-
const { strictEqual } = require('assert');
6+
const { strictEqual, throws } = require('assert');
7+
8+
{
9+
throws(() => {
10+
Readable.from(null);
11+
}, /ERR_INVALID_ARG_TYPE/);
12+
}
713

814
async function toReadableBasicSupport() {
915
async function* generate() {

Diff for: test/parallel/test-stream-add-abort-signal.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Flags: --expose-internals
2+
'use strict';
3+
4+
require('../common');
5+
const assert = require('assert');
6+
const { addAbortSignal, Readable } = require('stream');
7+
const {
8+
addAbortSignalNoValidate,
9+
} = require('internal/streams/add-abort-signal');
10+
11+
{
12+
assert.throws(() => {
13+
addAbortSignal('INVALID_SIGNAL');
14+
}, /ERR_INVALID_ARG_TYPE/);
15+
16+
const ac = new AbortController();
17+
assert.throws(() => {
18+
addAbortSignal(ac.signal, 'INVALID_STREAM');
19+
}, /ERR_INVALID_ARG_TYPE/);
20+
}
21+
22+
{
23+
const r = new Readable({
24+
read: () => {},
25+
});
26+
assert.deepStrictEqual(r, addAbortSignalNoValidate('INVALID_SIGNAL', r));
27+
}

Diff for: test/parallel/test-stream-writable-destroy.js

+15
Original file line numberDiff line numberDiff line change
@@ -446,3 +446,18 @@ const assert = require('assert');
446446
write.write('asd');
447447
ac.abort();
448448
}
449+
450+
{
451+
const ac = new AbortController();
452+
ac.abort();
453+
454+
const write = new Writable({
455+
signal: ac.signal,
456+
write(chunk, enc, cb) { cb(); }
457+
});
458+
459+
write.on('error', common.mustCall((e) => {
460+
assert.strictEqual(e.name, 'AbortError');
461+
assert.strictEqual(write.destroyed, true);
462+
}));
463+
}

0 commit comments

Comments
 (0)