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 {
17
17
return this . _client . handleMessage ;
18
18
}
19
19
20
+ get connected ( ) {
21
+ return this . _client . connected ;
22
+ }
23
+
20
24
publish ( ...args ) {
21
25
return new Promise ( ( resolve , reject ) => {
22
26
this . _client . publish ( ...args , ( err , result ) => {
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
1
3
const Server = require ( 'mqtt/test/server' ) ;
2
4
3
5
const AsyncMQTT = require ( './' ) ;
@@ -33,6 +35,17 @@ function runTests () {
33
35
} ) ;
34
36
} ) ;
35
37
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
+
36
49
test ( 'Calling end() should resolve once disconnected' , t => {
37
50
t . plan ( 2 ) ;
38
51
You can’t perform that action at this time.
0 commit comments