Skip to content

Commit 9905cfb

Browse files
committed
unit test for not duplicating event listeners
1 parent 6e33069 commit 9905cfb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
const assert = require('assert');
3+
const net = require('net');
4+
5+
const socket = new net.Socket();
6+
socket.on('error', () => {});
7+
socket.connect({ host: 'non-existing.domain', port: 1234 });
8+
socket.destroySoon();
9+
socket.connect({ host: 'non-existing.domain', port: 1234 });
10+
socket.destroySoon();
11+
const finishListenersCount = socket.listeners('finish').length;
12+
const connectListenersCount = socket.listeners('connect').length;
13+
assert.equal(finishListenersCount, 1);
14+
assert.equal(connectListenersCount, 1);

0 commit comments

Comments
 (0)