Skip to content

Commit f0cc971

Browse files
committed
[test] Add test for 20585ee
1 parent 20585ee commit f0cc971

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

test/WebSocketServer.test.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ describe('WebSocketServer', function () {
238238
});
239239
});
240240

241-
it('is updated when client closes the connection', function (done) {
241+
it('is updated when client closes the connection (1/2)', function (done) {
242242
const wss = new WebSocketServer({ port: ++port }, () => {
243243
const ws = new WebSocket(`ws://localhost:${port}`);
244244

@@ -253,6 +253,21 @@ describe('WebSocketServer', function () {
253253
});
254254
});
255255
});
256+
257+
it('is updated when client closes the connection (2/2)', function (done) {
258+
const wss = new WebSocketServer({ port: ++port }, () => {
259+
const ws = new WebSocket(`ws://localhost:${port}`);
260+
261+
ws.onopen = () => ws.close();
262+
});
263+
264+
wss.on('connection', (ws) => {
265+
ws.onclose = () => {
266+
assert.strictEqual(wss.clients.size, 0);
267+
wss.close(done);
268+
};
269+
});
270+
});
256271
});
257272

258273
describe('#options', function () {

0 commit comments

Comments
 (0)