File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ( ) {
You can’t perform that action at this time.
0 commit comments