Allow node.status() to be passed number/bool types

Adds to the existing support for string types. Also
adds unit tests for all three cases
This commit is contained in:
Nick O'Leary
2019-10-14 13:06:59 +01:00
parent 147d2a02be
commit c1c694035d
2 changed files with 33 additions and 4 deletions

View File

@@ -613,9 +613,6 @@ describe('Node', function() {
}
var n = new RedNode({_flow:flow,id:'123',type:'abc'});
var status = {fill:"green",shape:"dot",text:"connected"};
var topic;
var message;
var retain;
n.status(status);
@@ -624,6 +621,33 @@ describe('Node', function() {
flow.handleStatus.args[0][1].should.eql(status);
done();
});
it('publishes status for plain string', function(done) {
var flow = { handleStatus: sinon.stub() }
var n = new RedNode({_flow:flow,id:'123',type:'abc'});
n.status("text status");
flow.handleStatus.called.should.be.true();
flow.handleStatus.args[0][0].should.eql(n);
flow.handleStatus.args[0][1].should.eql({text:"text status"});
done();
});
it('publishes status for plain boolean', function(done) {
var flow = { handleStatus: sinon.stub() }
var n = new RedNode({_flow:flow,id:'123',type:'abc'});
n.status(false);
flow.handleStatus.called.should.be.true();
flow.handleStatus.args[0][0].should.eql(n);
flow.handleStatus.args[0][1].should.eql({text:"false"});
done();
});
it('publishes status for plain number', function(done) {
var flow = { handleStatus: sinon.stub() }
var n = new RedNode({_flow:flow,id:'123',type:'abc'});
n.status(123);
flow.handleStatus.called.should.be.true();
flow.handleStatus.args[0][0].should.eql(n);
flow.handleStatus.args[0][1].should.eql({text:"123"});
done();
});
});
});