Skip to content

Commit

Permalink
fix(selectInputsForOutput): send correct message
Browse files Browse the repository at this point in the history
We were previously sending the result of Array.unshift, which returns the length of the new array,
rather than the new array. This change sends the correct message.

fix #4
  • Loading branch information
hughrawlinson committed May 23, 2019
1 parent 9e75a70 commit ff46ac7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/wekinator-node.js
Expand Up @@ -185,14 +185,14 @@
var address = '/selectInputsForOutput';
self.queuePush({
address: self.controlEndpoint+address,
args: inputs.unshift(output)
args: [output].concat(inputs)
});
};
wekinatorNode.prototype.trainOnData = function(data){
self.startRecording();
for(var i = 0; i < data.length; i++){
// We're not *too* worried about the input arriving before the output
// because we handle queueing internally.
// We're not *too* worried about the input arriving before the output
// because we handle queueing internally.
self.outputs(data[i].outputs);
self.inputs(data[i].inputs);
}
Expand Down
5 changes: 2 additions & 3 deletions test/wekinator-node.test.js
Expand Up @@ -237,11 +237,10 @@ test('selectInputsForOutput sends correct OSC message', function() {

wn.connect(() => {
expect(wn.selectInputsForOutput).toThrow();
wn.selectInputsForOutput(0,[1,2,-3]);
//TODO: I believe this arg is a bug, see #4
wn.selectInputsForOutput(0,[1,2,3]);
expect(oscMock.UDPPort.prototype.send.mock.calls[0][0]).toEqual({
address: "/wekinator/control/selectInputsForOutput",
args: 4
args: [0,1,2,3]
});
});
});
Expand Down

0 comments on commit ff46ac7

Please sign in to comment.