node/test/parallel/test-stream-wrap.js
Sam Roberts 00944c7cc2 src: use consistent names for JSStream
Its confusing to call a js class with a handle a "Wrap", usually it's
the C++ handle that is called a Wrap (tcp_wrap, tls_wrap, ...). Its
derived from Socket, and makes a JS stream look like a Socket, so call
it that. Also, remove use of lib/_stream_wrap.js so it can be deprecated
some time.

PR-URL: https://github.com/nodejs/node/pull/25153
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
2018-12-28 12:57:46 -08:00

34 lines
760 B
JavaScript

// Flags: --expose-internals
'use strict';
const common = require('../common');
const assert = require('assert');
const { internalBinding } = require('internal/test/binding');
const StreamWrap = require('internal/js_stream_socket');
const { Duplex } = require('stream');
const { ShutdownWrap } = internalBinding('stream_wrap');
function testShutdown(callback) {
const stream = new Duplex({
read: function() {
},
write: function() {
}
});
const wrap = new StreamWrap(stream);
const req = new ShutdownWrap();
req.oncomplete = function(code) {
assert(code < 0);
callback();
};
req.handle = wrap._handle;
// Close the handle to simulate
wrap.destroy();
req.handle.shutdown(req);
}
testShutdown(common.mustCall());