11'use strict'
22
33const test = require ( 'tape' )
4- const mqtt = require ( '../../lib/connect ' )
4+ const mqtt = require ( '../../dist/mqtt.min ' )
55const _URL = require ( 'url' )
66// eslint-disable-next-line
77const parsed = _URL . parse ( document . URL )
@@ -22,7 +22,7 @@ client.on('reconnect', function () {
2222} )
2323
2424test ( 'MQTT.js browser test' , function ( t ) {
25- t . plan ( 4 )
25+ t . plan ( 6 )
2626 client . on ( 'connect' , function ( ) {
2727 client . on ( 'message' , function ( topic , msg ) {
2828 t . equal ( topic , 'hello' , 'should match topic' )
@@ -31,9 +31,21 @@ test('MQTT.js browser test', function (t) {
3131 t . pass ( 'client should close' )
3232 } )
3333 } )
34- client . subscribe ( 'hello' , function ( ) {
35- } ) . publish ( 'hello' , 'Hello World!' )
34+
35+ client . subscribe ( 'hello' , function ( err ) {
36+ t . error ( err , 'no error on subscribe' )
37+ if ( ! err ) {
38+ client . publish ( 'hello' , 'Hello World!' , function ( err ) {
39+ t . error ( err , 'no error on publish' )
40+ } )
41+ }
42+ } )
3643 } )
44+
45+ client . on ( 'error' , function ( err ) {
46+ t . fail ( err , 'no error' )
47+ } )
48+
3749 client . once ( 'close' , function ( ) {
3850 t . pass ( 'should emit close' )
3951 } )
0 commit comments