Skip to content

Commit

Permalink
add test for wildcards in pub sub mode
Browse files Browse the repository at this point in the history
  • Loading branch information
StarpTech committed May 19, 2017
1 parent a105f31 commit 5a23529
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/hemera/wildcards.spec.js
Expand Up @@ -66,6 +66,50 @@ describe('Topic wildcards', function () {
})
})

it('Should be able to use token wildcard in pubsub mode', function (done) {
const nats = require('nats').connect(authUrl)

const hemera = new Hemera(nats)

hemera.ready(() => {
hemera.add({
topic: 'systems-europe.a.>',
cmd: 'info'
}, (req) => {
expect(req.topic).to.be.equals('systems-europe.a.info.details')
hemera.close()
done()
})
hemera.act({
topic: 'systems-europe.a.info.details',
cmd: 'info',
pubsub$: true
})
})
})

it('Should be able to use full wildcard in pubsub mode', function (done) {
const nats = require('nats').connect(authUrl)

const hemera = new Hemera(nats)

hemera.ready(() => {
hemera.add({
topic: 'systems-europe.a.*',
cmd: 'info'
}, (req) => {
expect(req.topic).to.be.equals('systems-europe.a.info')
hemera.close()
done()
})
hemera.act({
topic: 'systems-europe.a.info',
cmd: 'info',
pubsub$: true
})
})
})

it('Should not convert topic without wildcard tokens', function (done) {
const nats = require('nats').connect(authUrl)

Expand Down

0 comments on commit 5a23529

Please sign in to comment.