summaryrefslogtreecommitdiff
path: root/cli/tests/node_compat/test/parallel/test-net-socket-connect-without-cb.js
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/node_compat/test/parallel/test-net-socket-connect-without-cb.js')
-rw-r--r--cli/tests/node_compat/test/parallel/test-net-socket-connect-without-cb.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/cli/tests/node_compat/test/parallel/test-net-socket-connect-without-cb.js b/cli/tests/node_compat/test/parallel/test-net-socket-connect-without-cb.js
new file mode 100644
index 000000000..8f8109380
--- /dev/null
+++ b/cli/tests/node_compat/test/parallel/test-net-socket-connect-without-cb.js
@@ -0,0 +1,33 @@
+// deno-fmt-ignore-file
+// deno-lint-ignore-file
+
+// Copyright Joyent and Node contributors. All rights reserved. MIT license.
+// Taken from Node 18.12.1
+// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
+
+'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();
+ }));
+
+ const address = server.address();
+ if (!common.hasIPv6 && address.family === 'IPv6') {
+ // Necessary to pass CI running inside containers.
+ client.connect(address.port);
+ } else {
+ client.connect(address);
+ }
+}));