node/test/parallel/test-stream-readable-dispose.js

24 lines
563 B
JavaScript
Raw Permalink Normal View History

'use strict';
const common = require('../common');
const { Readable } = require('stream');
const assert = require('assert');
{
const read = new Readable({
read() {}
});
read.resume();
read.on('end', common.mustNotCall('no end event'));
read.on('close', common.mustCall());
read.on('error', common.mustCall((err) => {
assert.strictEqual(err.name, 'AbortError');
}));
read[Symbol.asyncDispose]().then(common.mustCall(() => {
assert.strictEqual(read.errored.name, 'AbortError');
assert.strictEqual(read.destroyed, true);
}));
}