Skip to content

Commit

Permalink
test: use emitter.listenerCount() in test-http-connect
Browse files Browse the repository at this point in the history
Use `emitter.listenerCount()` instead of the `length` property of the
array returned by `emitter.listeners()`.

PR-URL: #26031
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
lpinca authored and targos committed Feb 14, 2019
1 parent 32e6bb3 commit 64cc234
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions test/parallel/test-http-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit 64cc234

Please sign in to comment.