node-poweredup icon indicating copy to clipboard operation
node-poweredup copied to clipboard

Unit tests draft

Open aileo opened this issue 4 years ago • 4 comments

Attempt to create a test suite to check logic without physical devices.

  • mock BLE device to send/receive messages
  • for each lpf2 hub:
    • check connection process
    • check supported version control
  • for each lpf2 hub device:
    • check device attachment

Also fix _requestHubPropertyValue so it will reject if _parseHubPropertyResponse throws.

aileo avatar Jul 03 '20 13:07 aileo

@aileo Hi, apologies for taking a while to get to this, I've taken some time off this project to work on a couple of other things - and work is busy at the moment. :)

I tried this PR, and it's awesome! I wanted to add unit tests but never gotten round to it, so it's awesome you did this!

To be honest, I'm perfectly happy merging this as is - it works great, tests pass, and it adds a lot to the project.

The only thing is that when I run npm run build:all it complains about test/test.ts existing outside of rootDir. :)

nathankellenicki avatar Jul 30 '20 20:07 nathankellenicki

Hi, apologies for taking a while to get to this, I've taken some time off this project to work on a couple of other things - and work is busy at the moment. :)

Very nice tchoo-tchoo videos :)

I tried this PR, and it's awesome! I wanted to add unit tests but never gotten round to it, so it's awesome you did this!

To be honest, I'm perfectly happy merging this as is - it works great, tests pass, and it adds a lot to the project.

The only thing is that when I run npm run build:all it complains about test/test.ts existing outside of rootDir. :)

I'm happy if you're happy :D I tried to deal with the compiling error, but it ended not compiling at all so I am asking for support :) I think I should write tests for at least one device before merging so it shows what is expected if anyone wants to contribute... But I don't know myself where to start, maybe the simplest ones (current, voltage, hub button and hub led), what do you think ?

aileo avatar Jul 31 '20 19:07 aileo

Very nice tchoo-tchoo videos :)

I decided to have some fun and actually write some code that uses this library for once. ;)

I think I should write tests for at least one device before merging so it shows what is expected if anyone wants to contribute... But I don't know myself where to start, maybe the simplest ones (current, voltage, hub button and hub led), what do you think ?

I think that's a great idea. Perhaps one output device and one input device as a demonstration of both? I think Hub Button and Hub LED would both be good candidates for this.

nathankellenicki avatar Aug 01 '20 04:08 nathankellenicki

Hi, sorry for the delay, I finally got back on this lib.

I think that's a great idea. Perhaps one output device and one input device as a demonstration of both? I think Hub Button and Hub LED would both be good candidates for this.

I wrote tests for the HubLED Device but the Hub buttons are not devices so I will go for the remotecontrolbutton instead.

aileo avatar Jan 25 '21 16:01 aileo