Skip to content

Commit

Permalink
Abstract test for empty levels (#23)
Browse files Browse the repository at this point in the history
* abstract test for empty levels

* added comment

* use more explicit options/names for test
  • Loading branch information
robertsLando authored Mar 30, 2020
1 parent e8ad462 commit 2f9a1e5
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions abstractTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,33 @@ module.exports = function abstractTests (opts) {
})
})

test('support deep wildcard - match empty words', function (t) {
t.plan(2)

const e = builder({ matchEmptyLevels: true })
const expected = {
topic: 'hello',
payload: { my: 'message' }
}

const wrong = {
topic: 'hellooo',
payload: { my: 'message' }
}

e.on('hello/#', function (message, cb) {
t.equal(message.topic, expected.topic)
cb()
}, function () {
e.emit(wrong) // this should not be received
e.emit(expected, function () {
e.close(function () {
t.pass('closed')
})
})
})
})

test('support changing deep wildcard', function (t) {
t.plan(2)

Expand Down

0 comments on commit 2f9a1e5

Please sign in to comment.