Add remove node api

This commit is contained in:
Nick O'Leary
2014-08-07 22:20:06 +01:00
parent 43ad8706aa
commit 58c2f5dd3d
5 changed files with 77 additions and 16 deletions

View File

@@ -139,6 +139,8 @@ describe("red/nodes/index", function() {
sinon.stub(registry,"getNodeInfo",function(id) {
if (id == "test") {
return {id:"1234",types:["test"]};
} else if (id == "doesnotexist") {
return null;
} else {
return randomNodeInfo;
}
@@ -164,8 +166,7 @@ describe("red/nodes/index", function() {
}).otherwise(function(err) {
done(err);
});
});
});
it(': prevents removing a node type that is in use',function(done) {
index.init({}, storage);
@@ -180,8 +181,23 @@ describe("red/nodes/index", function() {
}).otherwise(function(err) {
done(err);
});
});
it(': prevents removing a node type that is unknown',function(done) {
index.init({}, storage);
index.registerType('test', TestNode);
index.loadFlows().then(function() {
/*jshint immed: false */
(function() {
index.removeNode("doesnotexist");
}).should.throw();
done();
}).otherwise(function(err) {
done(err);
});
});
});

View File

@@ -384,7 +384,24 @@ describe('NodeRegistry', function() {
}).catch(function(e) {
done(e);
});
});
it('rejects removing unknown nodes from the registry', function(done) {
typeRegistry.init({});
typeRegistry.load("wontexist",true).then(function() {
var list = typeRegistry.getNodeList();
list.should.be.an.Array.and.be.empty;
/*jshint immed: false */
(function() {
typeRegistry.removeNode("1234");
}).should.throw();
done();
}).catch(function(e) {
done(e);
});
});
it('scans the node_modules path for node files', function(done) {