mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge branch '0.18' into projects
This commit is contained in:
@@ -26,11 +26,11 @@ var registry = require("../../../../red/runtime/nodes/registry");
|
||||
|
||||
describe("red/nodes/index", function() {
|
||||
before(function() {
|
||||
sinon.stub(flows,"startFlows");
|
||||
sinon.stub(index,"startFlows");
|
||||
process.env.NODE_RED_HOME = path.resolve(path.join(__dirname,"..","..","..",".."))
|
||||
});
|
||||
after(function() {
|
||||
flows.startFlows.restore();
|
||||
index.startFlows.restore();
|
||||
delete process.env.NODE_RED_HOME;
|
||||
});
|
||||
|
||||
|
@@ -150,7 +150,46 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
});
|
||||
it.skip("finds locales directory");
|
||||
it.skip("finds icon path directory");
|
||||
|
||||
it("scans icon files in the resources tree",function(done) {
|
||||
var count = 0;
|
||||
localfilesystem.init({
|
||||
i18n:{registerMessageCatalog:function(){}},
|
||||
events:{emit:function(eventName,dir){
|
||||
if (count === 0) {
|
||||
eventName.should.equal("node-icon-dir");
|
||||
dir.name.should.equal("node-red");
|
||||
dir.icons.should.be.an.Array();
|
||||
count = 1;
|
||||
} else if (count === 1) {
|
||||
done();
|
||||
}
|
||||
}},
|
||||
settings:{coreNodesDir:resourcesDir}
|
||||
});
|
||||
localfilesystem.getNodeFiles(true);
|
||||
});
|
||||
it("scans icons dir in library",function(done) {
|
||||
var count = 0;
|
||||
localfilesystem.init({
|
||||
i18n:{registerMessageCatalog:function(){}},
|
||||
events:{emit:function(eventName,dir){
|
||||
eventName.should.equal("node-icon-dir");
|
||||
if (count === 0) {
|
||||
dir.name.should.equal("node-red");
|
||||
dir.icons.should.be.an.Array();
|
||||
count = 1;
|
||||
} else if (count === 1) {
|
||||
dir.name.should.equal("Library");
|
||||
dir.icons.should.be.an.Array();
|
||||
dir.icons.length.should.equal(1);
|
||||
dir.icons[0].should.be.equal("test_icon.png");
|
||||
done();
|
||||
}
|
||||
}},
|
||||
settings:{userDir:userDir}
|
||||
});
|
||||
localfilesystem.getNodeFiles(true);
|
||||
});
|
||||
});
|
||||
describe("#getModuleFiles",function() {
|
||||
it("gets a nodes module files",function(done) {
|
||||
@@ -196,5 +235,27 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
});
|
||||
it.skip("finds locales directory");
|
||||
it.skip("finds icon path directory");
|
||||
it("scans icon files with a module file",function(done) {
|
||||
var _join = path.join;
|
||||
stubs.push(sinon.stub(path,"join",function() {
|
||||
if (arguments[0] == resourcesDir) {
|
||||
// This stops the module tree scan from going any higher
|
||||
// up the tree than resourcesDir.
|
||||
return arguments[0];
|
||||
}
|
||||
return _join.apply(null,arguments);
|
||||
}));
|
||||
localfilesystem.init({
|
||||
i18n:{registerMessageCatalog:function(){}},
|
||||
events:{emit:function(eventName,dir){
|
||||
eventName.should.equal("node-icon-dir");
|
||||
dir.name.should.equal("TestNodeModule");
|
||||
dir.icons.should.be.an.Array();
|
||||
done();
|
||||
}},
|
||||
settings:{coreNodesDir:moduleDir}
|
||||
});
|
||||
var nodeModule = localfilesystem.getModuleFiles('TestNodeModule');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -72,7 +72,15 @@ describe("red/nodes/registry/registry",function() {
|
||||
config: "configC",
|
||||
types: [ "test-c","test-d"]
|
||||
};
|
||||
|
||||
var testNodeSet3 = {
|
||||
id: "test-module-2/test-name-3",
|
||||
module: "test-module-2",
|
||||
name: "test-name-3",
|
||||
enabled: true,
|
||||
loaded: false,
|
||||
config: "configB",
|
||||
types: [ "test-a","test-e"]
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -198,7 +206,39 @@ describe("red/nodes/registry/registry",function() {
|
||||
typeRegistry.addNodeSet("test-module/test-name-2",testNodeSet2WithError, "0.0.1");
|
||||
|
||||
should.not.exist(typeRegistry.getTypeId("test-c"));
|
||||
});
|
||||
});
|
||||
|
||||
it('doesnt add node set if type already exists', function() {
|
||||
typeRegistry.init(settings);
|
||||
typeRegistry.getNodeList().should.have.lengthOf(0);
|
||||
typeRegistry.getModuleList().should.eql({});
|
||||
|
||||
should.not.exist(typeRegistry.getTypeId("test-e"));
|
||||
|
||||
typeRegistry.addNodeSet("test-module/test-name",testNodeSet1, "0.0.1");
|
||||
typeRegistry.getNodeList().should.have.lengthOf(1);
|
||||
should.exist(typeRegistry.getTypeId("test-a"));
|
||||
typeRegistry.addNodeSet(testNodeSet3.id,testNodeSet3, "0.0.1");
|
||||
typeRegistry.getNodeList().should.have.lengthOf(2);
|
||||
|
||||
// testNodeSet3 registers a duplicate test-a and unique test-e
|
||||
// as test-a is a duplicate, test-e should not get registered
|
||||
should.not.exist(typeRegistry.getTypeId("test-e"));
|
||||
|
||||
var testNodeSet3Result = typeRegistry.getNodeList()[1];
|
||||
should.exist(testNodeSet3Result.err);
|
||||
testNodeSet3Result.err.code.should.equal("type_already_registered");
|
||||
testNodeSet3Result.err.details.type.should.equal("test-a");
|
||||
testNodeSet3Result.err.details.moduleA.should.equal("test-module");
|
||||
testNodeSet3Result.err.details.moduleB.should.equal("test-module-2");
|
||||
|
||||
//
|
||||
// typeRegistry.addNodeSet("test-module/test-name-2",testNodeSet2WithError, "0.0.1");
|
||||
//
|
||||
// should.not.exist(typeRegistry.getTypeId("test-c"));
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe("#enableNodeSet", function() {
|
||||
@@ -334,7 +374,7 @@ describe("red/nodes/registry/registry",function() {
|
||||
enabled: true,
|
||||
loaded: false,
|
||||
config: "configB",
|
||||
types: [ "test-a","test-b"]
|
||||
types: [ "test-c","test-d"]
|
||||
}, "0.0.1");
|
||||
typeRegistry.getNodeConfig("test-module/test-name-2").should.eql('configBHEtest-name-2LP');
|
||||
typeRegistry.getAllNodeConfigs().should.eql('configAHEtest-nameLPconfigBHEtest-name-2LP');
|
||||
@@ -493,7 +533,7 @@ describe("red/nodes/registry/registry",function() {
|
||||
|
||||
it('returns a registered icon' , function() {
|
||||
var testIcon = path.resolve(__dirname+'/../../../../resources/icons/test_icon.png');
|
||||
events.emit("node-icon-dir",{name:"test-module", path: path.resolve(__dirname+'/../../../../resources/icons')});
|
||||
events.emit("node-icon-dir",{name:"test-module", path: path.resolve(__dirname+'/../../../../resources/icons'), icons:[]});
|
||||
var iconPath = typeRegistry.getNodeIconPath('test-module','test_icon.png');
|
||||
iconPath.should.eql(testIcon);
|
||||
});
|
||||
@@ -505,4 +545,24 @@ describe("red/nodes/registry/registry",function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getNodeIcons', function() {
|
||||
it('returns empty icon list when no modules are registered', function() {
|
||||
var iconList = typeRegistry.getNodeIcons();
|
||||
iconList.should.eql({});
|
||||
});
|
||||
|
||||
it('returns an icon list of registered node module', function() {
|
||||
typeRegistry.addNodeSet("test-module/test-name",testNodeSet1,"0.0.1");
|
||||
events.emit("node-icon-dir",{name:"test-module", path:"",icons:["test_icon1.png"]});
|
||||
var iconList = typeRegistry.getNodeIcons();
|
||||
iconList.should.eql({"test-module":["test_icon1.png"]});
|
||||
});
|
||||
|
||||
it('returns an icon list of unregistered node module', function() {
|
||||
events.emit("node-icon-dir",{name:"test-module", path:"", icons:["test_icon1.png", "test_icon2.png"]});
|
||||
var iconList = typeRegistry.getNodeIcons();
|
||||
iconList.should.eql({"test-module":["test_icon1.png","test_icon2.png"]});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
BIN
test/red/runtime/nodes/resources/userDir/lib/icons/test_icon.png
Normal file
BIN
test/red/runtime/nodes/resources/userDir/lib/icons/test_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 163 B |
Reference in New Issue
Block a user