From 4093572c4dcdb9796fa7a401ac971c487a1f19be Mon Sep 17 00:00:00 2001 From: ajido Date: Mon, 5 Nov 2018 04:10:12 +0900 Subject: [PATCH] test: add test for socket.end callback PR-URL: https://github.com/nodejs/node/pull/24087 Refs: https://github.com/nodejs/node/pull/23937 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-net-socket-end-callback.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/parallel/test-net-socket-end-callback.js diff --git a/test/parallel/test-net-socket-end-callback.js b/test/parallel/test-net-socket-end-callback.js new file mode 100644 index 00000000000000..6aa53251f502a6 --- /dev/null +++ b/test/parallel/test-net-socket-end-callback.js @@ -0,0 +1,22 @@ +'use strict'; + +const common = require('../common'); +const net = require('net'); + +const server = net.createServer((socket) => { + socket.resume(); +}).unref(); + +server.listen(common.mustCall(() => { + const connect = (...args) => { + const socket = net.createConnection(server.address().port, () => { + socket.end(...args); + }); + }; + + const cb = common.mustCall(() => {}, 3); + + connect(cb); + connect('foo', cb); + connect('foo', 'utf8', cb); +}));