@@ -54,7 +54,7 @@ describe('websockets', function() {
5454 } ) ;
5555} ) ;
5656
57- describe ( 'server crashed, with reconnect: false (default)' , function ( ) {
57+ describe ( 'server crashed, with reconnect: true (default)' , function ( ) {
5858 before ( function ( ) {
5959 // Initialize websocket server
6060 this . server = new WebSocketServer ( { port : 7000 } ) ;
@@ -66,7 +66,7 @@ describe('server crashed, with reconnect: false (default)', function() {
6666 } ) ;
6767 } ) ;
6868
69- it ( 'gracefully handle the error ' , function ( cb ) {
69+ it ( 'attempt to reconnect ' , function ( cb ) {
7070 this . timeout ( 15000 ) ;
7171 const client = this . client ;
7272 const server = this . server ;
@@ -77,28 +77,30 @@ describe('server crashed, with reconnect: false (default)', function() {
7777 } ) ;
7878
7979 client . on ( 'disconnected' , function ( ) {
80- 'Test that we reached this point' . should . be . ok ( ) ;
81- cb ( ) ;
80+ setTimeout ( function ( ) {
81+ 'Test that we reached this point' . should . be . ok ( ) ;
82+ cb ( ) ;
83+ } , client . reconnectTimer ) ;
8284 } ) ;
8385
8486 client . connect ( ) . catch ( catchConnectError ) ;
8587 } ) ;
8688} ) ;
8789
88- describe ( 'server crashed, with reconnect: true ' , function ( ) {
90+ describe ( 'server crashed, with reconnect: false ' , function ( ) {
8991 before ( function ( ) {
9092 // Initialize websocket server
9193 this . server = new WebSocketServer ( { port : 7000 } ) ;
9294 this . client = new tmi . client ( {
9395 connection : {
9496 server : 'localhost' ,
9597 port : 7000 ,
96- reconnect : true
98+ reconnect : false
9799 }
98100 } ) ;
99101 } ) ;
100102
101- it ( 'attempt to reconnect ' , function ( cb ) {
103+ it ( 'gracefully handle the error ' , function ( cb ) {
102104 this . timeout ( 15000 ) ;
103105 const client = this . client ;
104106 const server = this . server ;
@@ -109,10 +111,8 @@ describe('server crashed, with reconnect: true', function() {
109111 } ) ;
110112
111113 client . on ( 'disconnected' , function ( ) {
112- setTimeout ( function ( ) {
113- 'Test that we reached this point' . should . be . ok ( ) ;
114- cb ( ) ;
115- } , client . reconnectTimer ) ;
114+ 'Test that we reached this point' . should . be . ok ( ) ;
115+ cb ( ) ;
116116 } ) ;
117117
118118 client . connect ( ) . catch ( catchConnectError ) ;
0 commit comments