1 | Exchange = require '../index'
|
2 | _ = require 'lodash'
|
3 |
|
4 | describe 'Connection', ->
|
5 | randomQueue = "test queue #{ String(Math.random()).substring 1 }"
|
6 | ex2 = null
|
7 |
|
8 |
|
9 | before (done)->
|
10 | ex2 = new Exchange 'test.exchange2', {host:'localhost'}, {logLevel:'FATAL'}
|
11 |
|
12 | ex2.exchangeReady
|
13 | .then -> ex2.getQueue(randomQueue)
|
14 | .then -> ex2.bindQueue(randomQueue, 'long.#.pattern')
|
15 | .then -> done()
|
16 |
|
17 | after ->
|
18 | ex2.queues[randomQueue].destroy()
|
19 |
|
20 | it 'should connect', (done)->
|
21 | ex = new Exchange 'test.exchange', {host:'localhost'}, {logLevel:'WARN'}
|
22 | ex.exchangeReady.then (ex) -> done()
|
23 |
|
24 | it 'should be able to subscribe and push immediately', (done)->
|
25 | ex = new Exchange 'test.exchange2', {host:'localhost'}, {logLevel:'WARN'}
|
26 | ex.subscribe randomQueue, (message, headers, deliveryInfo, messageObj) ->
|
27 | message.text.should.equal 'test message'
|
28 | done()
|
29 |
|
30 | ex.push {text: 'test message'}, {}, 'long.rabbitmq.pattern'
|