diff --git a/packages/node_modules/@node-red/runtime/lib/nodes/Node.js b/packages/node_modules/@node-red/runtime/lib/nodes/Node.js index c58fa65cc..c465f0b5b 100644 --- a/packages/node_modules/@node-red/runtime/lib/nodes/Node.js +++ b/packages/node_modules/@node-red/runtime/lib/nodes/Node.js @@ -539,7 +539,12 @@ Node.prototype.metric = function(eventname, msg, metricValue) { * status: "simple text status" */ Node.prototype.status = function(status) { - if (typeof(status) === "string") { status = {text:status}; } + switch (typeof status) { + case "string": + case "number": + case "boolean": + status = {text:""+status} + } this._flow.handleStatus(this,status); }; diff --git a/test/unit/@node-red/runtime/lib/nodes/Node_spec.js b/test/unit/@node-red/runtime/lib/nodes/Node_spec.js index 5ad52211e..1f9ca04ce 100644 --- a/test/unit/@node-red/runtime/lib/nodes/Node_spec.js +++ b/test/unit/@node-red/runtime/lib/nodes/Node_spec.js @@ -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(); + }); }); });