diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2024-06-14 23:07:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-15 00:07:02 +0200 |
commit | 78b12a43b307c3405cd63cf4612517210330b487 (patch) | |
tree | ef9a6a258f13f7d4151e8152ed9702572126c165 /tests/node_compat/test/parallel/test-diagnostics-channel-net.js | |
parent | 184a85eaecbe7055b5b3969391f49c4723ac44fb (diff) |
fix(ext/node): better support for `node:diagnostics_channel` module (#24088)
Closes https://github.com/denoland/deno/issues/24060
Diffstat (limited to 'tests/node_compat/test/parallel/test-diagnostics-channel-net.js')
-rw-r--r-- | tests/node_compat/test/parallel/test-diagnostics-channel-net.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/node_compat/test/parallel/test-diagnostics-channel-net.js b/tests/node_compat/test/parallel/test-diagnostics-channel-net.js new file mode 100644 index 000000000..504c3e5dc --- /dev/null +++ b/tests/node_compat/test/parallel/test-diagnostics-channel-net.js @@ -0,0 +1,32 @@ +// 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 `tests/node_compat/runner/setup.ts`. Do not modify this file manually. + +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); +const dc = require('diagnostics_channel'); + +const isNetSocket = (socket) => socket instanceof net.Socket; + +dc.subscribe('net.client.socket', common.mustCall(({ socket }) => { + assert.strictEqual(isNetSocket(socket), true); +})); + +dc.subscribe('net.server.socket', common.mustCall(({ socket }) => { + assert.strictEqual(isNetSocket(socket), true); +})); + +const server = net.createServer(common.mustCall((socket) => { + socket.destroy(); + server.close(); +})); + +server.listen(() => { + const { port } = server.address(); + net.connect(port); +}); |