File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ class AsyncClient {
1717 return this . _client . handleMessage ;
1818 }
1919
20+ get connected ( ) {
21+ return this . _client . connected ;
22+ }
23+
2024 publish ( ...args ) {
2125 return new Promise ( ( resolve , reject ) => {
2226 this . _client . publish ( ...args , ( err , result ) => {
Original file line number Diff line number Diff line change 1+ 'use strict'
2+
13const Server = require ( 'mqtt/test/server' ) ;
24
35const AsyncMQTT = require ( './' ) ;
@@ -33,6 +35,17 @@ function runTests () {
3335 } ) ;
3436 } ) ;
3537
38+ test ( 'client.connected should be true' , t => {
39+ t . plan ( 1 ) ;
40+
41+ const client = AsyncMQTT . connect ( SERVER_URL ) ;
42+
43+ client . once ( 'connect' , ( ) => {
44+ t . equal ( client . connected , true )
45+ client . end ( ) ;
46+ } ) ;
47+ } ) ;
48+
3649 test ( 'Calling end() should resolve once disconnected' , t => {
3750 t . plan ( 2 ) ;
3851
You can’t perform that action at this time.
0 commit comments