File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,10 @@ class AsyncClient {
6161 } )
6262 }
6363
64+ reconnect ( ...args ) {
65+ return this . _client . reconnect ( ...args ) ;
66+ }
67+
6468 addListener ( ...args ) {
6569 return this . _client . addListener ( ...args ) ;
6670 }
Original file line number Diff line number Diff line change @@ -131,6 +131,26 @@ function runTests () {
131131 return client . end ( ) ;
132132 } ) ;
133133 } ) ;
134+
135+ test ( 'Calling reconnect after end should resolve once reconnect' , t => {
136+ t . plan ( 2 ) ;
137+
138+ const client = AsyncMQTT . connect ( SERVER_URL ) ;
139+
140+ client . once ( 'reconnect' , ( ) => {
141+ t . pass ( 'Reconnect event occured' ) ;
142+ client . once ( 'connect' , ( ) => {
143+ client . end ( ) ;
144+ } ) ;
145+ } ) ;
146+
147+ client . once ( 'connect' , ( ) => {
148+ client . end ( ) . then ( ( ) => {
149+ t . pass ( 'End resolved' ) ;
150+ client . reconnect ( ) ;
151+ } ) ;
152+ } ) ;
153+ } ) ;
134154}
135155
136156// Taken from MQTT.js tests
You can’t perform that action at this time.
0 commit comments