I'd like to propose some tests that we can add to this project so that updates can be made with higher confidence that they don't change the existing behaviour.
My wish-list would be to have high coverage of the public APIs exported by this package. I'll create a PR that updates the npm test script to run mocha against some Connection and Session tests as a base to build on. (I chose mocha to match what rhea is using.)
Here's a list of tests I think should be added based on the API that's exposed today. This list doesn't cover 100% of the API (some error validation would be nice) but should at least cover the happy path.
Connection
Session
RequestResponseLink
Sender
AwaitableSender
Receiver
I'd like to propose some tests that we can add to this project so that updates can be made with higher confidence that they don't change the existing behaviour.
My wish-list would be to have high coverage of the public APIs exported by this package. I'll create a PR that updates the npm test script to run mocha against some
ConnectionandSessiontests as a base to build on. (I chose mocha to match what rhea is using.)Here's a list of tests I think should be added based on the API that's exposed today. This list doesn't cover 100% of the API (some error validation would be nice) but should at least cover the happy path.
Connection
Ensure the connection is in an 'opened' state after Connection.open() yields.
Ensure the connection is no longer in an 'opened' state after Connection.close() yields.
Ensure
isOpen()istrueafterConnection.open()yields.Ensure
isOpen()isfalseafterConnection.close()yields.Ensure
isRemoteOpen()istrueafterConnection.open()yields.Ensure
isRemoteOpen()isfalseafterConnection.close()yields.Ensure the connection fires the
connectionOpenevent whenConnection.open()is called.Ensure the connection fires the
connectionCloseevent whenConnection.close()is called.Ensure the connection fires the
connectionErrorevent when service closes the connection with an error.Ensure the session is created and in an
openstate.Call
createSender()without a session and ensure the sender is created and in anopenstate.Call
createSender()with a session and ensure the sender is created and in anopenstate.Ensure the sender is created and in an
openstate.Ensure the receiver is created and in an
openstate.Ensure the RequestResponseLink is created and in an
openstate.Create a session via
Connection.createSession(), remove session viaConnection.removeSession()and ensuresession.remove()is called.Session
Ensure the session fires the
sessionOpenevent.Ensure the session is fully closed after
Session.close()yields.Ensure
isOpen()istrueafterconnection.createSessionresolves.Ensure
isOpen()istrueafter thesessionOpenevent is fired.Ensure
isClosed()istrueafterSession.close()yields.Ensure
isItselfClosed()istrueafterSession.close()yields.Ensure the session does not have any event listeners registered.
Ensure the session fires the
sessionOpenevent aftersession.begin()is called.Ensure the session fires the
sessionCloseevent aftersession.close()is called.Ensure
session.connectionmatches theConnectionused to instantiate theSession.Ensure the sender is created and in an
openstate.Ensure the sender is created and in an
openstate.Ensure the receiver is created and in an
openstate.RequestResponseLink
Call method without
providedSessionand ensure the return value includes the following fields,each in theopenstate:sessionsenderreceiverCall method with
providedSessionand ensure thesessionin the return value matches thesessionprovided.Sender
Ensure
isOpen()returnstrueafterconnection.createSender()resolves.Ensure
isRemoteOpen()returnstrueafterconnection.createSender()resolves.Ensure
isClosedreturnstrueaftersender.close()resolves.Ensure
isItselfClosedreturnstrueaftersender.close()resolves.Ensure
isSender()returns true.Ensure
isReceiver()returns false.Ensure the
senderand thesessiondo not have any event listeners registered.Don't set
closeSession, and ensuresenderandsessionare closed.Set
closeSessiontotrue, and ensuresenderandsessionare closed.Set
closeSessiontofalse, and ensuresenderis closed andsessionis open.Returns the sender's name.
Ensure the
sender.sessionmatches theSessionused to instantiate theSender.Ensure the
sender.connectionmatches theConnectionused to instantiate theSender.Ensure
set_drained()is called on the rhea link.Ensure
sendable()is called on the rhea link.Ensure
send()is called on the rhea link with message, tag and format.AwaitableSender
Ensure
sendis called on the rhea link with message, tag and format.Receiver
Ensure
isOpen()returnstrueafterconnection.createReceiver()resolves.Ensure
isRemoteOpen()returnstrueafterconnection.createReceiver()resolves.Ensure
isClosedreturnstrueafterreceiver.close()resolves.Ensure
isItselfClosedreturnstrueafterreceiver.close()resolves.Ensure
isSender()returnsfalse.Ensure
isReceiver()returnstrue.Ensure the
receiverand thesessiondo not have any event listeners registered.Don't set
closeSession, and ensurereceiverandsessionare closed.Set
closeSessiontotrue, and ensurereceiverandsessionare closed.Set
closeSessiontofalse, and ensurereceiveris closed andsessionis open.Returns the receiver's name.
Ensure the
receiver.sessionmatches theSessionused to instantiate theReceiver.Ensure the
receiver.connectionmatches theConnectionused to instantiate theReceiver.