diff options
author | Juwan Yoo <vhain6512@gmail.com> | 2017-03-09 06:36:15 +0300 |
---|---|---|
committer | Italo A. Casas <me@italoacasas.com> | 2017-03-13 18:38:36 +0300 |
commit | 1dff218cd1d31b867190c000a34f141213c2b3f3 (patch) | |
tree | eec354ebcfde50dccab0337ad73b198dbb846a65 /test | |
parent | 52f0092f54db5635190682b12408e6b82c2b3461 (diff) |
net: allow missing callback for Socket.connect
Arguments of Socket.prototype.connect should be also normalized,
causing error when called without callback.
Changed Socket.prototype.connect's code same as net.connect and added
test.
Fixes: https://github.com/nodejs/node/issues/11761
PR-URL: https://github.com/nodejs/node/pull/11762
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-net-socket-connect-without-cb.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/parallel/test-net-socket-connect-without-cb.js b/test/parallel/test-net-socket-connect-without-cb.js new file mode 100644 index 00000000000..468b29a3a48 --- /dev/null +++ b/test/parallel/test-net-socket-connect-without-cb.js @@ -0,0 +1,20 @@ +'use strict'; +const common = require('../common'); + +// This test ensures that socket.connect can be called without callback +// which is optional. + +const net = require('net'); + +const server = net.createServer(common.mustCall(function(conn) { + conn.end(); + server.close(); +})).listen(0, common.mustCall(function() { + const client = new net.Socket(); + + client.on('connect', common.mustCall(function() { + client.end(); + })); + + client.connect(server.address()); +})); |