Skip to content

Commit

Permalink
Added a unit test
Browse files Browse the repository at this point in the history
'subscribe a client programmatically - wildcard'
  • Loading branch information
gnought committed Aug 10, 2019
1 parent b33b5c1 commit 0a5add6
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/client-pub-sub.js
Expand Up @@ -353,6 +353,44 @@ test('subscribe a client programmatically', function (t) {
})
})

test('subscribe a client programmatically - wildcard', function (t) {
t.plan(3)

var broker = aedes()
var expected = {
cmd: 'publish',
topic: 'hello/world/1',
payload: Buffer.from('world'),
dup: false,
length: 20,
qos: 0,
retain: false
}

broker.on('clientReady', function (client) {
client.subscribe({
topic: '+/world/1',
qos: 0
}, function (err) {
t.error(err, 'no error')

broker.publish({
topic: 'hello/world/1',
payload: Buffer.from('world'),
qos: 0
}, function (err) {
t.error(err, 'no error')
})
})
})

var s = connect(setup(broker))

s.outStream.once('data', function (packet) {
t.deepEqual(packet, expected, 'packet matches')
})
})

test('unsubscribe a client', function (t) {
t.plan(2)

Expand Down

0 comments on commit 0a5add6

Please sign in to comment.