@@ -3,16 +3,12 @@ const { tokenFor, openIdConfiguration } = require('../utils')
33const { reset, expectUser, expectVhost, expectResource, allow, verifyAll } = require ( '../mock_http_backend' )
44const { open : openAmqp , once : onceAmqp , on : onAmqp , close : closeAmqp } = require ( '../amqp' )
55
6- var receivedAmqpMessageCount = 0
76var untilConnectionEstablished = new Promise ( ( resolve , reject ) => {
87 onAmqp ( 'connection_open' , function ( context ) {
98 resolve ( )
109 } )
1110} )
1211
13- onAmqp ( 'message' , function ( context ) {
14- receivedAmqpMessageCount ++
15- } )
1612onceAmqp ( 'sendable' , function ( context ) {
1713 context . sender . send ( { body :'first message' } )
1814} )
@@ -52,16 +48,21 @@ describe('Having AMQP 1.0 protocol enabled and the following auth_backends: ' +
5248 } )
5349
5450 it ( 'can open an AMQP 1.0 connection' , async function ( ) {
51+ var untilFirstMessageReceived = new Promise ( ( resolve , reject ) => {
52+ onAmqp ( 'message' , function ( context ) {
53+ resolve ( )
54+ } )
55+ } )
5556 amqp = openAmqp ( )
5657 await untilConnectionEstablished
57- var untilMessageReceived = new Promise ( ( resolve , reject ) => {
58+ await untilFirstMessageReceived
59+ var untilSecondMessageReceived = new Promise ( ( resolve , reject ) => {
5860 onAmqp ( 'message' , function ( context ) {
5961 resolve ( )
6062 } )
6163 } )
6264 amqp . sender . send ( { body :'second message' } )
63- await untilMessageReceived
64- assert . equal ( 2 , receivedAmqpMessageCount )
65+ await untilSecondMessageReceived
6566 } )
6667
6768 after ( function ( ) {
0 commit comments