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

Updated registry tests to reflect id changes

This commit is contained in:
Anna Thomas 2014-11-20 12:15:09 +00:00
parent 591b5f3f91
commit 0ff65f6805

View File

@ -33,10 +33,10 @@ describe('NodeRegistry', function() {
var resourcesDir = __dirname+ path.sep + "resources" + path.sep;
function stubSettings(s,available) {
s.available = function() {return available;}
s.set = function(s,v) { return when.resolve()},
s.get = function(s) { return null;}
return s
s.available = function() {return available;};
s.set = function(s,v) { return when.resolve();};
s.get = function(s) { return null;};
return s;
}
var settings = stubSettings({},false);
var settingsWithStorage = stubSettings({},true);
@ -56,8 +56,9 @@ describe('NodeRegistry', function() {
typeRegistry.load(resourcesDir + "TestNode1",true).then(function() {
var list = typeRegistry.getNodeList();
list.should.be.an.Array.and.have.lengthOf(1);
list[0].should.have.property("id");
list[0].should.have.property("name","TestNode1.js");
list[0].should.have.property("id","node-red/TestNode1");
list[0].should.have.property("name","TestNode1");
list[0].should.have.property("module","node-red");
list[0].should.have.property("types",["test-node-1"]);
list[0].should.have.property("enabled",true);
list[0].should.not.have.property("err");
@ -78,8 +79,9 @@ describe('NodeRegistry', function() {
typeRegistry.load(resourcesDir + "TestNode2",true).then(function() {
var list = typeRegistry.getNodeList();
list.should.be.an.Array.and.have.lengthOf(1);
list[0].should.have.property("id");
list[0].should.have.property("name","TestNode2.js");
list[0].should.have.property("id","node-red/TestNode2");
list[0].should.have.property("name","TestNode2");
list[0].should.have.property("module","node-red");
list[0].should.have.property("types",["test-node-2"]);
list[0].should.have.property("enabled",true);
list[0].should.not.have.property("err");
@ -98,8 +100,9 @@ describe('NodeRegistry', function() {
typeRegistry.load(resourcesDir + "TestNode3",true).then(function() {
var list = typeRegistry.getNodeList();
list.should.be.an.Array.and.have.lengthOf(1);
list[0].should.have.property("id");
list[0].should.have.property("name","TestNode3.js");
list[0].should.have.property("id","node-red/TestNode3");
list[0].should.have.property("name","TestNode3");
list[0].should.have.property("module","node-red");
list[0].should.have.property("types",["test-node-3"]);
list[0].should.have.property("enabled",true);
list[0].should.have.property("err","fail");
@ -119,8 +122,9 @@ describe('NodeRegistry', function() {
typeRegistry.load(resourcesDir + "MultipleNodes1",true).then(function() {
var list = typeRegistry.getNodeList();
list.should.be.an.Array.and.have.lengthOf(1);
list[0].should.have.property("id");
list[0].should.have.property("name","MultipleNodes1.js");
list[0].should.have.property("id","node-red/MultipleNodes1");
list[0].should.have.property("name","MultipleNodes1");
list[0].should.have.property("module","node-red");
list[0].should.have.property("types",["test-node-multiple-1a","test-node-multiple-1b"]);
list[0].should.have.property("enabled",true);
list[0].should.not.have.property("err");
@ -142,8 +146,9 @@ describe('NodeRegistry', function() {
typeRegistry.load(resourcesDir + "NestedDirectoryNode",true).then(function() {
var list = typeRegistry.getNodeList();
list.should.be.an.Array.and.have.lengthOf(1);
list[0].should.have.property("id");
list[0].should.have.property("name","NestedNode.js");
list[0].should.have.property("id","node-red/NestedNode");
list[0].should.have.property("name","NestedNode");
list[0].should.have.property("module","node-red");
list[0].should.have.property("types",["nested-node-1"]);
list[0].should.have.property("enabled",true);
list[0].should.not.have.property("err");
@ -159,7 +164,9 @@ describe('NodeRegistry', function() {
typeRegistry.load(resourcesDir + "NestedDirectoryNode",true).then(function() {
var list = typeRegistry.getNodeList();
list.should.be.an.Array.and.have.lengthOf(1);
list[0].should.have.property("name","NestedNode.js");
list[0].should.have.property("id","node-red/NestedNode");
list[0].should.have.property("name","NestedNode");
list[0].should.have.property("module","node-red");
list[0].should.have.property("types",["nested-node-1"]);
list[0].should.have.property("enabled",true);
list[0].should.not.have.property("err");
@ -189,26 +196,13 @@ describe('NodeRegistry', function() {
typeRegistry.load("wontexist",true).then(function() {
var list = typeRegistry.getNodeList();
list.should.be.an.Array.and.have.lengthOf(2);
list[0].should.have.property("id");
list[0].should.have.property("name","TestNode1.js");
list.should.be.an.Array.and.have.lengthOf(1);
list[0].should.have.property("id","node-red/TestNode1");
list[0].should.have.property("name","TestNode1");
list[0].should.have.property("types",["test-node-1"]);
list[0].should.have.property("enabled",true);
list[0].should.not.have.property("err");
list[1].should.have.property("id");
list[1].id.should.not.equal(list[0].id);
list[1].should.have.property("name","TestNode1.js");
list[1].should.have.property("types",["test-node-1"]);
list[1].should.have.property("enabled",true);
list[1].should.have.property("err");
/already registered/.test(list[1].err).should.be.true;
var nodeConstructor = typeRegistry.get("test-node-1");
// Verify the duplicate node hasn't replaced the original one
nodeConstructor.name.should.be.equal("TestNode");
done();
}).catch(function(e) {
done(e);
@ -336,10 +330,12 @@ describe('NodeRegistry', function() {
var list = typeRegistry.getNodeList();
list.should.be.an.Array.and.be.empty;
// TODO: Needs module and name params for loadNodeConfig
typeRegistry.addNode(resourcesDir + "TestNode1/TestNode1.js").then(function(node) {
list = typeRegistry.getNodeList();
list[0].should.have.property("id");
list[0].should.have.property("name","TestNode1.js");
list[0].should.have.property("id","node-red/TestNode1");
list[0].should.have.property("name","TestNode1");
list[0].should.have.property("module","node-red");
list[0].should.have.property("types",["test-node-1"]);
list[0].should.have.property("enabled",true);
list[0].should.not.have.property("err");
@ -386,8 +382,9 @@ describe('NodeRegistry', function() {
var id = list[0].id;
var type = list[0].types[0];
list[0].should.have.property("id");
list[0].should.have.property("name","TestNode1.js");
list[0].should.have.property("id","node-red/TestNode1");
list[0].should.have.property("name","TestNode1");
list[0].should.have.property("module","node-red");
list[0].should.have.property("types",["test-node-1"]);
list[0].should.have.property("enabled",true);
list[0].should.not.have.property("err");
@ -532,8 +529,9 @@ describe('NodeRegistry', function() {
typeRegistry.load(resourcesDir + "TestNode1",true).then(function() {
var list = typeRegistry.getNodeList();
list.should.be.an.Array.and.have.lengthOf(1);
list[0].should.have.property("id");
list[0].should.have.property("name","TestNode1.js");
list[0].should.have.property("id","node-red/TestNode1");
list[0].should.have.property("name","TestNode1");
list[0].should.have.property("module","node-red");
list[0].should.have.property("types",["test-node-1"]);
list[0].should.have.property("enabled",true);
list[0].should.have.property("loaded",true);
@ -612,14 +610,16 @@ describe('NodeRegistry', function() {
typeRegistry.load("wontexist",false).then(function(){
var list = typeRegistry.getNodeList();
list.should.be.an.Array.and.have.lengthOf(2);
list[0].should.have.property("id");
list[0].should.have.property("name","TestNodeModule:TestNodeMod1");
list[0].should.have.property("id","TestNodeModule/TestNodeMod1");
list[0].should.have.property("name","TestNodeMod1");
list[0].should.have.property("module","TestNodeModule");
list[0].should.have.property("types",["test-node-mod-1"]);
list[0].should.have.property("enabled",true);
list[0].should.not.have.property("err");
list[1].should.have.property("id");
list[1].should.have.property("name","TestNodeModule:TestNodeMod2");
list[1].should.have.property("id","TestNodeModule/TestNodeMod2");
list[1].should.have.property("name","TestNodeMod2");
list[1].should.have.property("module","TestNodeModule");
list[1].should.have.property("types",["test-node-mod-2"]);
list[1].should.have.property("enabled",true);
list[1].should.have.property("err");
@ -681,14 +681,16 @@ describe('NodeRegistry', function() {
typeRegistry.addModule("TestNodeModule").then(function(node) {
list = typeRegistry.getNodeList();
list.should.be.an.Array.and.have.lengthOf(2);
list[0].should.have.property("id");
list[0].should.have.property("name","TestNodeModule:TestNodeMod1");
list[0].should.have.property("id","TestNodeModule/TestNodeMod1");
list[0].should.have.property("name","TestNodeMod1");
list[0].should.have.property("module","TestNodeModule");
list[0].should.have.property("types",["test-node-mod-1"]);
list[0].should.have.property("enabled",true);
list[0].should.not.have.property("err");
list[1].should.have.property("id");
list[1].should.have.property("name","TestNodeModule:TestNodeMod2");
list[1].should.have.property("id","TestNodeModule/TestNodeMod2");
list[1].should.have.property("name","TestNodeMod2");
list[1].should.have.property("module","TestNodeModule");
list[1].should.have.property("types",["test-node-mod-2"]);
list[1].should.have.property("enabled",true);
list[1].should.have.property("err");
@ -847,13 +849,14 @@ describe('NodeRegistry', function() {
});
it('allows nodes to be enabled and disabled by hex-id', function(done) {
it('allows nodes to be enabled and disabled by id', function(done) {
typeRegistry.init(settingsWithStorage);
typeRegistry.load(resourcesDir+path.sep+"TestNode1",true).then(function() {
var list = typeRegistry.getNodeList();
list.should.be.an.Array.and.have.lengthOf(1);
list[0].should.have.property("id");
list[0].should.have.property("name","TestNode1.js");
list[0].should.have.property("id","node-red/TestNode1");
list[0].should.have.property("name","TestNode1");
list[0].should.have.property("module","node-red");
list[0].should.have.property("enabled",true);
var nodeConfig = typeRegistry.getNodeConfigs();
@ -892,8 +895,9 @@ describe('NodeRegistry', function() {
var list = typeRegistry.getNodeList();
list.should.be.an.Array.and.have.lengthOf(1);
list[0].should.have.property("id");
list[0].should.have.property("name","TestNode1.js");
list[0].should.have.property("id","node-red/TestNode1");
list[0].should.have.property("name","TestNode1");
list[0].should.have.property("module","node-red");
list[0].should.have.property("types",["test-node-1"]);
list[0].should.have.property("enabled",true);