File tree Expand file tree Collapse file tree 5 files changed +24
-13
lines changed Expand file tree Collapse file tree 5 files changed +24
-13
lines changed Original file line number Diff line number Diff line change @@ -27,15 +27,20 @@ jobs:
27
27
with :
28
28
node-version : ${{ matrix.node-version }}
29
29
cache : ' npm'
30
- - run : npm ci
31
- - name : Node Tests
30
+
31
+ - name : Install Dependencies
32
+ run : npm ci
33
+
34
+ - name : Test NodeJS
32
35
run : npm run test:node
33
36
env :
34
37
CI : true
35
38
DEBUG : " mqttjs"
39
+
36
40
- name : Test Typescript
37
41
run : npm run test:typescript
38
42
env :
39
43
CI : true
40
44
DEBUG : " mqttjs"
41
45
46
+
Original file line number Diff line number Diff line change @@ -17,9 +17,9 @@ const validations = require('./validations')
17
17
const xtend = require ( 'xtend' )
18
18
const debug = require ( 'debug' ) ( 'mqttjs:client' )
19
19
const nextTick = process ? process . nextTick : function ( callback ) { setTimeout ( callback , 0 ) }
20
- const setImmediate = global . setImmediate || function ( callback ) {
21
- const args = arguments . slice ( 1 )
22
- process . nextTick ( callback . bind ( null , ...args ) )
20
+ const setImmediate = global . setImmediate || function ( ... args ) {
21
+ const callback = args . shift ( )
22
+ nextTick ( callback . bind ( null , ...args ) )
23
23
}
24
24
25
25
const defaultConnectOptions = {
Original file line number Diff line number Diff line change 123
123
"mkdirp" : " ^0.5.1" ,
124
124
"mocha" : " ^9.2.0" ,
125
125
"mqtt-connection" : " ^4.0.0" ,
126
+ "mqtt-level-store" : " ^3.1.0" ,
126
127
"nyc" : " ^15.0.1" ,
127
128
"pre-commit" : " ^1.2.2" ,
128
129
"release-it" : " ^15.11.0" ,
133
134
"standard" : " ^16.0.4" ,
134
135
"tape" : " ^5.5.2" ,
135
136
"terser" : " ^5.14.2" ,
136
- "typescript" : " ^4.5.5" ,
137
- "mqtt-level-store" : " ^3.1.0"
137
+ "typescript" : " ^4.5.5"
138
138
},
139
139
"standard" : {
140
140
"env" : [
Original file line number Diff line number Diff line change @@ -116,12 +116,14 @@ function start (startPort, done) {
116
116
return server
117
117
}
118
118
119
+ const port = process . env . PORT || process . env . AIRTAP_SUPPORT_PORT
120
+
119
121
if ( require . main === module ) {
120
- start ( process . env . PORT || process . env . AIRTAP_PORT , function ( err ) {
122
+ start ( port , function ( err ) {
121
123
if ( err ) {
122
124
console . error ( err )
123
125
return
124
126
}
125
- console . log ( 'tunnelled server started on port' , process . env . PORT || process . env . AIRTAP_PORT )
127
+ console . log ( 'tunnelled server started on port' , port )
126
128
} )
127
129
}
Original file line number Diff line number Diff line change @@ -22,15 +22,19 @@ client.on('reconnect', function () {
22
22
} )
23
23
24
24
test ( 'MQTT.js browser test' , function ( t ) {
25
- t . plan ( 2 )
25
+ t . plan ( 4 )
26
26
client . on ( 'connect' , function ( ) {
27
- client . on ( 'message' , function ( msg ) {
28
- t . equal ( msg , 'Hello World!' )
27
+ client . on ( 'message' , function ( topic , msg ) {
28
+ t . equal ( topic , 'hello' , 'should match topic' )
29
+ t . equal ( msg . toString ( ) , 'Hello World!' , 'should match payload' )
30
+ client . end ( ( ) => {
31
+ t . pass ( 'client should close' )
32
+ } )
29
33
} )
30
34
client . subscribe ( 'hello' , function ( ) {
31
35
} ) . publish ( 'hello' , 'Hello World!' )
32
36
} )
33
37
client . once ( 'close' , function ( ) {
34
- t . true ( true )
38
+ t . pass ( 'should emit close' )
35
39
} )
36
40
} )
You can’t perform that action at this time.
0 commit comments