From 64cc234a84cdabedd058ff8deee47cb04087c623 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Sun, 10 Feb 2019 12:13:09 +0100 Subject: [PATCH] test: use emitter.listenerCount() in test-http-connect Use `emitter.listenerCount()` instead of the `length` property of the array returned by `emitter.listeners()`. PR-URL: https://github.com/nodejs/node/pull/26031 Reviewed-By: James M Snell Reviewed-By: Daniel Bevenius Reviewed-By: Anna Henningsen --- test/parallel/test-http-connect.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/parallel/test-http-connect.js b/test/parallel/test-http-connect.js index ec2c8846bbb134..6483c93dd70204 100644 --- a/test/parallel/test-http-connect.js +++ b/test/parallel/test-http-connect.js @@ -31,11 +31,11 @@ server.on('connect', common.mustCall((req, socket, firstBodyChunk) => { assert.strictEqual(req.url, 'google.com:443'); // Make sure this socket has detached. - assert.strictEqual(socket.listeners('close').length, 0); - assert.strictEqual(socket.listeners('drain').length, 0); - assert.strictEqual(socket.listeners('data').length, 0); - assert.strictEqual(socket.listeners('end').length, 1); - assert.strictEqual(socket.listeners('error').length, 0); + assert.strictEqual(socket.listenerCount('close'), 0); + assert.strictEqual(socket.listenerCount('drain'), 0); + assert.strictEqual(socket.listenerCount('data'), 0); + assert.strictEqual(socket.listenerCount('end'), 1); + assert.strictEqual(socket.listenerCount('error'), 0); socket.write('HTTP/1.1 200 Connection established\r\n\r\n'); @@ -72,14 +72,14 @@ server.listen(0, common.mustCall(() => { assert(!socket.ondata); assert(!socket.onend); assert.strictEqual(socket._httpMessage, null); - assert.strictEqual(socket.listeners('connect').length, 0); - assert.strictEqual(socket.listeners('data').length, 0); - assert.strictEqual(socket.listeners('drain').length, 0); - assert.strictEqual(socket.listeners('end').length, 1); - assert.strictEqual(socket.listeners('free').length, 0); - assert.strictEqual(socket.listeners('close').length, 0); - assert.strictEqual(socket.listeners('error').length, 0); - assert.strictEqual(socket.listeners('agentRemove').length, 0); + assert.strictEqual(socket.listenerCount('connect'), 0); + assert.strictEqual(socket.listenerCount('data'), 0); + assert.strictEqual(socket.listenerCount('drain'), 0); + assert.strictEqual(socket.listenerCount('end'), 1); + assert.strictEqual(socket.listenerCount('free'), 0); + assert.strictEqual(socket.listenerCount('close'), 0); + assert.strictEqual(socket.listenerCount('error'), 0); + assert.strictEqual(socket.listenerCount('agentRemove'), 0); let data = firstBodyChunk.toString(); socket.on('data', (buf) => {