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