xbee-api icon indicating copy to clipboard operation
xbee-api copied to clipboard

Unit Testing XBEE - mock

Open jonhardman opened this issue 8 years ago • 3 comments

Hi, I have been using this api for a while now and it is great :-)

I was wondering if anyone has figured out how to mock out a xbee packet to simulate a number of packets arriving through the serial channel.

Thanks in advance!

Jon

jonhardman avatar Nov 23 '16 17:11 jonhardman

I mocked part of the library for tests in xbee-rx. The mock is here and one instance of its use is here.

101100 avatar Nov 23 '16 17:11 101100

Thanks for the advice, will look into it :-). I've only used the xbee-api so far and not the xbee-rx version, would you say there is value in moving to the rx version?

jonhardman avatar Nov 28 '16 16:11 jonhardman

@jonhardman xbee-rx builds upon xbee-api and takes care of the serial port connection and pairing off API calls with their responses. It is based upon RxJS and provides streams for command results, messages and responses. The simpler xbee-promise library handles local and remote commands with promises but doesn't handle incoming messages (since the promise model only handles single events, not multiple events in a row like a sequence of incoming messages).

101100 avatar Nov 28 '16 17:11 101100