mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
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:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user