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 {
61
61
} )
62
62
}
63
63
64
+ reconnect ( ...args ) {
65
+ return this . _client . reconnect ( ...args ) ;
66
+ }
67
+
64
68
addListener ( ...args ) {
65
69
return this . _client . addListener ( ...args ) ;
66
70
}
Original file line number Diff line number Diff line change @@ -131,6 +131,26 @@ function runTests () {
131
131
return client . end ( ) ;
132
132
} ) ;
133
133
} ) ;
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
+ } ) ;
134
154
}
135
155
136
156
// Taken from MQTT.js tests
You can’t perform that action at this time.
0 commit comments