boost api index, nodes index and nodes Node test coverage

This commit is contained in:
dceejay
2015-03-06 22:58:30 +00:00
parent 910d983b82
commit 69f85bd688
5 changed files with 52 additions and 32 deletions

View File

@@ -417,14 +417,13 @@ describe('Node', function() {
});
var message = {a:1};
n.error("an error message",message);
should.deepEqual({level:Log.ERROR, id:n.id,
type:n.type, msg:"an error message"}, loginfo);
n.error(null,message);
should.deepEqual({level:Log.ERROR, id:n.id, type:n.type, msg:""}, loginfo);
flows.handleError.called.should.be.true;
flows.handleError.args[0][0].should.eql(n);
flows.handleError.args[0][1].should.eql("an error message");
flows.handleError.args[0][1].should.eql("");
flows.handleError.args[0][2].should.eql(message);
Log.log.restore();
@@ -448,8 +447,22 @@ describe('Node', function() {
done();
});
});
describe('#metric', function() {
it('returns metric value if eventname undefined', function(done) {
var n = new RedNode({id:'123',type:'abc'});
var loginfo = {};
sinon.stub(Log, 'log', function(msg) {
loginfo = msg;
});
var msg = {payload:"foo", _msgid:"987654321"};
var m = n.metric(undefined,msg,"15mb");
m.should.equal(true);
Log.log.restore();
done();
});
});
describe('#status', function() {
after(function() {
comms.publish.restore();

View File

@@ -58,7 +58,6 @@ describe("red/nodes/index", function() {
}
it('nodes are initialised with credentials',function(done) {
index.init(settings, storage);
index.registerType('test', TestNode);
index.loadFlows().then(function() {
@@ -69,7 +68,6 @@ describe("red/nodes/index", function() {
}).otherwise(function(err) {
done(err);
});
});
it('flows should be initialised',function(done) {
@@ -128,7 +126,7 @@ describe("red/nodes/index", function() {
foo: {type:"test"}
}
});
var testnode = new TestNode({id:'tab1',type:'test',name:'barney'});
var testnode = new TestNode({id:'tab1',type:'test',name:'barney', '_alias':'tab1'});
credentials.getDefinition("test").should.have.property('foo');
done();
});