1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Test Node.status calls through to Flow.handleStatus

This commit is contained in:
Nick O'Leary 2015-08-19 21:35:54 +01:00
parent d1ea689999
commit 40fe0f3239

View File

@ -516,16 +516,29 @@ describe('Node', function() {
comms.publish.restore();
});
it('publishes status', function(done) {
sinon.stub(flows,"handleStatus", function(node,message,msg) {});
var n = new RedNode({id:'123',type:'abc'});
var status = {fill:"green",shape:"dot",text:"connected"};
sinon.stub(comms, 'publish', function(topic, message, retain) {
topic.should.equal('status/123');
message.should.equal(status);
retain.should.be.true;
done();
var topic;
var message;
var retain;
sinon.stub(comms, 'publish', function(_topic, _message, _retain) {
topic = _topic;
message = _message;
retain = _retain;
});
n.status(status);
topic.should.equal('status/123');
message.should.equal(status);
retain.should.be.true;
flows.handleStatus.called.should.be.true;
flows.handleStatus.args[0][0].should.eql(n);
flows.handleStatus.args[0][1].should.eql(status);
flows.handleStatus.restore();
done();
});
});