Skip to content
This repository has been archived by the owner on Dec 20, 2019. It is now read-only.

Fixes connection error handling (cleaner PR) #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

olcar
Copy link

@olcar olcar commented Jan 16, 2016

But still failing 2 tests...

$ grunt
Running "lint" task

lib/adaptors/ble.js
  160:31  warning  Too many nested callbacks (4). Maximum allowed is 3  max-nested-callbacks
  162:23  warning  Too many nested callbacks (5). Maximum allowed is 3  max-nested-callbacks
  167:25  warning  Too many nested callbacks (5). Maximum allowed is 3  max-nested-callbacks
  408:0   warning  Line 408 exceeds the maximum line length of 80       max-len

lib/adaptors/serialport.js
  26:0  warning  Line 26 exceeds the maximum line length of 80  max-len

spec/lib/packet.spec.js
  685:0  warning  Line 685 exceeds the maximum line length of 80  max-len

✖ 6 problems (0 errors, 6 warnings)

Running "test" task


  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․
  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․
  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․
  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․

  271 passing (715ms)
  1 pending
  2 failing

  1) Serialport Adaptor #open "before each" hook:
     TypeError: port.open is not a function
      at Adaptor.open (lib/adaptors/serialport.js:61:8)
      at Context.<anonymous> (spec/lib/adaptors/serialport.spec.js:41:15)

  2) Core commands #getPowerState calls #command with params:
     AssertionError: expected command to have been called with arguments 0, 32, null, function spy() {}
    command(0, 32, null, function () {})
      at Context.<anonymous> (spec/lib/devices/core.spec.js:66:34)



Warning: Task "test" failed. Use --force to continue.

Aborted due to warnings.


function emit(name) {
return self.emit.bind(self, name);
}

port.on("open", function(error) {
port.open(function(error) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes the first test fail.

@jamuus seems like SerialPort doesn't support open()

  1) Serialport Adaptor #open "before each" hook:
     TypeError: port.open is not a function
      at Adaptor.open (lib/adaptors/serialport.js:61:8)
      at Context.<anonymous> (spec/lib/adaptors/serialport.spec.js:41:15)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olcar is exactly correct, Serialport fires open event if/when the port is opened after it has been created. Why change this?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for this change is described in #30. I'm not sure why the test fails, the code has been successfully working for me since the change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably need to stub the open method like port.open = stub(); inside the beforeEach code here https://github.com/orbotix/sphero.js/blob/master/spec/lib/adaptors/serialport.spec.js#L12-L16

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants