mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Finalise nodeSettings and update tlsConfigDisableLocalFiles
- increase test coverage around registerType
This commit is contained in:
parent
f45a2643f2
commit
5356373681
@ -82,7 +82,7 @@ module.exports = function(RED) {
|
|||||||
settings: {
|
settings: {
|
||||||
tlsConfigDisableLocalFiles: {
|
tlsConfigDisableLocalFiles: {
|
||||||
value: false,
|
value: false,
|
||||||
exportable: false
|
exportable: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -43,16 +43,12 @@ module.exports = {
|
|||||||
safeSettings.flowFilePretty = settings.flowFilePretty;
|
safeSettings.flowFilePretty = settings.flowFilePretty;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.tlsDisableLocalFiles) {
|
|
||||||
safeSettings.tlsDisableLocalFiles = settings.tlsDisableLocalFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!runtime.nodes.paletteEditorEnabled()) {
|
if (!runtime.nodes.paletteEditorEnabled()) {
|
||||||
safeSettings.editorTheme = safeSettings.editorTheme || {};
|
safeSettings.editorTheme = safeSettings.editorTheme || {};
|
||||||
safeSettings.editorTheme.palette = safeSettings.editorTheme.palette || {};
|
safeSettings.editorTheme.palette = safeSettings.editorTheme.palette || {};
|
||||||
safeSettings.editorTheme.palette.editable = false;
|
safeSettings.editorTheme.palette.editable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.exportNodeSettings(safeSettings);
|
settings.exportNodeSettings(safeSettings);
|
||||||
|
|
||||||
res.json(safeSettings);
|
res.json(safeSettings);
|
||||||
|
@ -24,7 +24,7 @@ var flows = require("./flows");
|
|||||||
var flowUtil = require("./flows/util")
|
var flowUtil = require("./flows/util")
|
||||||
var context = require("./context");
|
var context = require("./context");
|
||||||
var Node = require("./Node");
|
var Node = require("./Node");
|
||||||
var log = require("../log");
|
var log = null;
|
||||||
var library = require("./library");
|
var library = require("./library");
|
||||||
|
|
||||||
var events = require("../events");
|
var events = require("../events");
|
||||||
@ -55,7 +55,11 @@ function registerType(nodeSet,type,constructor,opts) {
|
|||||||
credentials.register(type,opts.credentials);
|
credentials.register(type,opts.credentials);
|
||||||
}
|
}
|
||||||
if (opts.settings) {
|
if (opts.settings) {
|
||||||
settings.registerNodeSettings(type,opts.settings);
|
try {
|
||||||
|
settings.registerNodeSettings(type,opts.settings);
|
||||||
|
} catch(err) {
|
||||||
|
log.warn("["+type+"] "+err.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
registry.registerType(nodeSet,type,constructor);
|
registry.registerType(nodeSet,type,constructor);
|
||||||
@ -90,6 +94,7 @@ function createNode(node,def) {
|
|||||||
|
|
||||||
function init(runtime) {
|
function init(runtime) {
|
||||||
settings = runtime.settings;
|
settings = runtime.settings;
|
||||||
|
log = runtime.log;
|
||||||
credentials.init(runtime);
|
credentials.init(runtime);
|
||||||
flows.init(runtime);
|
flows.init(runtime);
|
||||||
registry.init(runtime);
|
registry.init(runtime);
|
||||||
|
@ -106,19 +106,15 @@ var persistentSettings = {
|
|||||||
storage = null;
|
storage = null;
|
||||||
},
|
},
|
||||||
registerNodeSettings: function(type, opts) {
|
registerNodeSettings: function(type, opts) {
|
||||||
try {
|
var normalisedType = util.normaliseNodeTypeName(type);
|
||||||
for (var property in opts) {
|
for (var property in opts) {
|
||||||
if (opts.hasOwnProperty(property)) {
|
if (opts.hasOwnProperty(property)) {
|
||||||
var normalisedType = util.normaliseNodeTypeName(type);
|
if (!property.startsWith(normalisedType)) {
|
||||||
if (!property.startsWith(normalisedType)) {
|
throw new Error("Registered invalid property name '"+property+"'. Properties for this node must start with '"+normalisedType+"'");
|
||||||
throw new Error("The name of node setting property " + property + " must start with \"" + normalisedType + "\" (case sensitive).");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodeSettings[type] = opts;
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err.toString());
|
|
||||||
}
|
}
|
||||||
|
nodeSettings[type] = opts;
|
||||||
},
|
},
|
||||||
exportNodeSettings: function(safeSettings) {
|
exportNodeSettings: function(safeSettings) {
|
||||||
safeSettings["nodeSettings"] = {};
|
safeSettings["nodeSettings"] = {};
|
||||||
@ -131,7 +127,7 @@ var persistentSettings = {
|
|||||||
if (setting.exportable) {
|
if (setting.exportable) {
|
||||||
if (userSettings.hasOwnProperty(property)) {
|
if (userSettings.hasOwnProperty(property)) {
|
||||||
safeSettings["nodeSettings"][property] = userSettings[property];
|
safeSettings["nodeSettings"][property] = userSettings[property];
|
||||||
} else {
|
} else if (setting.hasOwnProperty('value')) {
|
||||||
safeSettings["nodeSettings"][property] = setting.value;
|
safeSettings["nodeSettings"][property] = setting.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,9 +72,9 @@ describe("red/nodes/index", function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
it('nodes are initialised with credentials',function(done) {
|
it('nodes are initialised with credentials',function(done) {
|
||||||
index.init(runtime);
|
index.init(runtime);
|
||||||
index.registerType('test', TestNode);
|
index.registerType('test-node-set','test', TestNode);
|
||||||
index.loadFlows().then(function() {
|
index.loadFlows().then(function() {
|
||||||
var testnode = new TestNode({id:'tab1',type:'test',name:'barney'});
|
var testnode = new TestNode({id:'tab1',type:'test',name:'barney'});
|
||||||
testnode.credentials.should.have.property('b',1);
|
testnode.credentials.should.have.property('b',1);
|
||||||
@ -86,11 +86,11 @@ describe("red/nodes/index", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('flows should be initialised',function(done) {
|
it('flows should be initialised',function(done) {
|
||||||
index.init(runtime);
|
index.init(runtime);
|
||||||
index.loadFlows().then(function() {
|
index.loadFlows().then(function() {
|
||||||
console.log(testFlows);
|
// console.log(testFlows);
|
||||||
console.log(index.getFlows());
|
// console.log(index.getFlows());
|
||||||
should.deepEqual(testFlows, index.getFlows().flows);
|
should.deepEqual(testFlows, index.getFlows().flows);
|
||||||
done();
|
done();
|
||||||
}).otherwise(function(err) {
|
}).otherwise(function(err) {
|
||||||
@ -98,86 +98,159 @@ describe("red/nodes/index", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
describe("registerType", function() {
|
||||||
|
describe("logs deprecated usage", function() {
|
||||||
|
before(function() {
|
||||||
|
sinon.stub(registry,"registerType");
|
||||||
|
});
|
||||||
|
after(function() {
|
||||||
|
registry.registerType.restore();
|
||||||
|
});
|
||||||
|
it("called without node-set name", function() {
|
||||||
|
var runtime = {
|
||||||
|
settings: settings,
|
||||||
|
storage: storage,
|
||||||
|
log: {debug:function() {}, warn:sinon.spy()},
|
||||||
|
events: new EventEmitter()
|
||||||
|
}
|
||||||
|
index.init(runtime);
|
||||||
|
|
||||||
describe("registerType should register credentials definition", function() {
|
index.registerType(/*'test-node-set',*/'test', TestNode, {});
|
||||||
var http = require('http');
|
runtime.log.warn.called.should.be.true();
|
||||||
var express = require('express');
|
registry.registerType.called.should.be.true();
|
||||||
var app = express();
|
registry.registerType.firstCall.args[0].should.eql('');
|
||||||
var runtime = require("../../../../red/runtime");
|
registry.registerType.firstCall.args[1].should.eql('test');
|
||||||
var credentials = require("../../../../red/runtime/nodes/credentials");
|
registry.registerType.firstCall.args[2].should.eql(TestNode);
|
||||||
var localfilesystem = require("../../../../red/runtime/storage/localfilesystem");
|
});
|
||||||
var RED = require("../../../../red/red.js");
|
});
|
||||||
|
|
||||||
var userDir = path.join(__dirname,".testUserHome");
|
describe("register credentials definition", function() {
|
||||||
before(function(done) {
|
var http = require('http');
|
||||||
fs.remove(userDir,function(err) {
|
var express = require('express');
|
||||||
fs.mkdir(userDir,function() {
|
var app = express();
|
||||||
sinon.stub(index, 'load', function() {
|
var runtime = require("../../../../red/runtime");
|
||||||
return when.promise(function(resolve,reject){
|
var credentials = require("../../../../red/runtime/nodes/credentials");
|
||||||
resolve([]);
|
var localfilesystem = require("../../../../red/runtime/storage/localfilesystem");
|
||||||
});
|
var log = require("../../../../red/runtime/log");
|
||||||
});
|
var RED = require("../../../../red/red.js");
|
||||||
sinon.stub(localfilesystem, 'getCredentials', function() {
|
|
||||||
return when.promise(function(resolve,reject) {
|
var userDir = path.join(__dirname,".testUserHome");
|
||||||
resolve({"tab1":{"b":1,"c":2}});
|
before(function(done) {
|
||||||
|
sinon.stub(log,"log");
|
||||||
|
fs.remove(userDir,function(err) {
|
||||||
|
fs.mkdir(userDir,function() {
|
||||||
|
sinon.stub(index, 'load', function() {
|
||||||
|
return when.promise(function(resolve,reject){
|
||||||
|
resolve([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
sinon.stub(localfilesystem, 'getCredentials', function() {
|
||||||
|
return when.promise(function(resolve,reject) {
|
||||||
|
resolve({"tab1":{"b":1,"c":2}});
|
||||||
|
});
|
||||||
|
}) ;
|
||||||
|
RED.init(http.createServer(function(req,res){app(req,res)}),
|
||||||
|
{userDir: userDir});
|
||||||
|
runtime.start().then(function () {
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
}) ;
|
|
||||||
RED.init(http.createServer(function(req,res){app(req,res)}),
|
|
||||||
{userDir: userDir});
|
|
||||||
runtime.start().then(function () {
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
after(function(done) {
|
after(function(done) {
|
||||||
fs.remove(userDir,function() {;
|
fs.remove(userDir,function() {;
|
||||||
runtime.stop().then(function() {
|
runtime.stop().then(function() {
|
||||||
index.load.restore();
|
index.load.restore();
|
||||||
localfilesystem.getCredentials.restore();
|
localfilesystem.getCredentials.restore();
|
||||||
done();
|
log.log.restore();
|
||||||
});
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it(': definition defined',function() {
|
it('definition defined',function() {
|
||||||
index.registerType('test', TestNode, {
|
index.registerType('test-node-set','test', TestNode, {
|
||||||
credentials: {
|
credentials: {
|
||||||
foo: {type:"test"}
|
foo: {type:"test"}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var testnode = new TestNode({id:'tab1',type:'test',name:'barney', '_alias':'tab1'});
|
var testnode = new TestNode({id:'tab1',type:'test',name:'barney', '_alias':'tab1'});
|
||||||
index.getCredentialDefinition("test").should.have.property('foo');
|
index.getCredentialDefinition("test").should.have.property('foo');
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
describe("register settings definition", function() {
|
||||||
|
beforeEach(function() {
|
||||||
|
sinon.stub(registry,"registerType");
|
||||||
|
})
|
||||||
|
afterEach(function() {
|
||||||
|
registry.registerType.restore();
|
||||||
|
})
|
||||||
|
it('registers valid settings',function() {
|
||||||
|
var runtime = {
|
||||||
|
settings: settings,
|
||||||
|
storage: storage,
|
||||||
|
log: {debug:function() {}, warn:function() {}},
|
||||||
|
events: new EventEmitter()
|
||||||
|
}
|
||||||
|
runtime.settings.registerNodeSettings = sinon.spy();
|
||||||
|
index.init(runtime);
|
||||||
|
|
||||||
describe('allows nodes to be added/removed/enabled/disabled from the registry', function() {
|
index.registerType('test-node-set','test', TestNode, {
|
||||||
var randomNodeInfo = {id:"5678",types:["random"]};
|
settings: {
|
||||||
|
testOne: {}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
runtime.settings.registerNodeSettings.called.should.be.true();
|
||||||
|
runtime.settings.registerNodeSettings.firstCall.args[0].should.eql('test');
|
||||||
|
runtime.settings.registerNodeSettings.firstCall.args[1].should.eql({testOne: {}});
|
||||||
|
});
|
||||||
|
it('logs invalid settings',function() {
|
||||||
|
var runtime = {
|
||||||
|
settings: settings,
|
||||||
|
storage: storage,
|
||||||
|
log: {debug:function() {}, warn:sinon.spy()},
|
||||||
|
events: new EventEmitter()
|
||||||
|
}
|
||||||
|
runtime.settings.registerNodeSettings = function() { throw new Error("pass");}
|
||||||
|
index.init(runtime);
|
||||||
|
|
||||||
beforeEach(function() {
|
index.registerType('test-node-set','test', TestNode, {
|
||||||
sinon.stub(registry,"getNodeInfo",function(id) {
|
settings: {
|
||||||
if (id == "test") {
|
testOne: {}
|
||||||
return {id:"1234",types:["test"]};
|
}
|
||||||
} else if (id == "doesnotexist") {
|
});
|
||||||
return null;
|
runtime.log.warn.called.should.be.true();
|
||||||
} else {
|
});
|
||||||
return randomNodeInfo;
|
});
|
||||||
}
|
});
|
||||||
});
|
|
||||||
sinon.stub(registry,"disableNode",function(id) {
|
|
||||||
return randomNodeInfo;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
afterEach(function() {
|
|
||||||
registry.getNodeInfo.restore();
|
|
||||||
registry.disableNode.restore();
|
|
||||||
});
|
|
||||||
|
|
||||||
it(': allows an unused node type to be disabled',function(done) {
|
describe('allows nodes to be added/removed/enabled/disabled from the registry', function() {
|
||||||
|
var randomNodeInfo = {id:"5678",types:["random"]};
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
sinon.stub(registry,"getNodeInfo",function(id) {
|
||||||
|
if (id == "test") {
|
||||||
|
return {id:"1234",types:["test"]};
|
||||||
|
} else if (id == "doesnotexist") {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return randomNodeInfo;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sinon.stub(registry,"disableNode",function(id) {
|
||||||
|
return randomNodeInfo;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
afterEach(function() {
|
||||||
|
registry.getNodeInfo.restore();
|
||||||
|
registry.disableNode.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows an unused node type to be disabled',function(done) {
|
||||||
index.init(runtime);
|
index.init(runtime);
|
||||||
index.registerType('test', TestNode);
|
index.registerType('test-node-set','test', TestNode);
|
||||||
index.loadFlows().then(function() {
|
index.loadFlows().then(function() {
|
||||||
var info = index.disableNode("5678");
|
var info = index.disableNode("5678");
|
||||||
registry.disableNode.calledOnce.should.be.true();
|
registry.disableNode.calledOnce.should.be.true();
|
||||||
@ -187,11 +260,11 @@ describe("red/nodes/index", function() {
|
|||||||
}).otherwise(function(err) {
|
}).otherwise(function(err) {
|
||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it(': prevents disabling a node type that is in use',function(done) {
|
it('prevents disabling a node type that is in use',function(done) {
|
||||||
index.init(runtime);
|
index.init(runtime);
|
||||||
index.registerType('test', TestNode);
|
index.registerType('test-node-set','test', TestNode);
|
||||||
index.loadFlows().then(function() {
|
index.loadFlows().then(function() {
|
||||||
/*jshint immed: false */
|
/*jshint immed: false */
|
||||||
(function() {
|
(function() {
|
||||||
@ -202,11 +275,11 @@ describe("red/nodes/index", function() {
|
|||||||
}).otherwise(function(err) {
|
}).otherwise(function(err) {
|
||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it(': prevents disabling a node type that is unknown',function(done) {
|
it('prevents disabling a node type that is unknown',function(done) {
|
||||||
index.init(runtime);
|
index.init(runtime);
|
||||||
index.registerType('test', TestNode);
|
index.registerType('test-node-set','test', TestNode);
|
||||||
index.loadFlows().then(function() {
|
index.loadFlows().then(function() {
|
||||||
/*jshint immed: false */
|
/*jshint immed: false */
|
||||||
(function() {
|
(function() {
|
||||||
@ -220,46 +293,46 @@ describe("red/nodes/index", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('allows modules to be removed from the registry', function() {
|
describe('allows modules to be removed from the registry', function() {
|
||||||
var registry = require("../../../../red/runtime/nodes/registry");
|
var registry = require("../../../../red/runtime/nodes/registry");
|
||||||
var randomNodeInfo = {id:"5678",types:["random"]};
|
var randomNodeInfo = {id:"5678",types:["random"]};
|
||||||
var randomModuleInfo = {
|
var randomModuleInfo = {
|
||||||
name:"random",
|
name:"random",
|
||||||
nodes: [randomNodeInfo]
|
nodes: [randomNodeInfo]
|
||||||
};
|
};
|
||||||
|
|
||||||
before(function() {
|
before(function() {
|
||||||
sinon.stub(registry,"getNodeInfo",function(id) {
|
sinon.stub(registry,"getNodeInfo",function(id) {
|
||||||
if (id == "node-red/foo") {
|
if (id == "node-red/foo") {
|
||||||
return {id:"1234",types:["test"]};
|
return {id:"1234",types:["test"]};
|
||||||
} else if (id == "doesnotexist") {
|
} else if (id == "doesnotexist") {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return randomNodeInfo;
|
return randomNodeInfo;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
sinon.stub(registry,"getModuleInfo",function(module) {
|
sinon.stub(registry,"getModuleInfo",function(module) {
|
||||||
if (module == "node-red") {
|
if (module == "node-red") {
|
||||||
return {nodes:[{name:"foo"}]};
|
return {nodes:[{name:"foo"}]};
|
||||||
} else if (module == "doesnotexist") {
|
} else if (module == "doesnotexist") {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return randomModuleInfo;
|
return randomModuleInfo;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
sinon.stub(registry,"removeModule",function(id) {
|
sinon.stub(registry,"removeModule",function(id) {
|
||||||
return randomModuleInfo;
|
return randomModuleInfo;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
after(function() {
|
after(function() {
|
||||||
registry.getNodeInfo.restore();
|
registry.getNodeInfo.restore();
|
||||||
registry.getModuleInfo.restore();
|
registry.getModuleInfo.restore();
|
||||||
registry.removeModule.restore();
|
registry.removeModule.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
it(': prevents removing a module that is in use',function(done) {
|
it('prevents removing a module that is in use',function(done) {
|
||||||
index.init(runtime);
|
index.init(runtime);
|
||||||
index.registerType('test', TestNode);
|
index.registerType('test-node-set','test', TestNode);
|
||||||
index.loadFlows().then(function() {
|
index.loadFlows().then(function() {
|
||||||
/*jshint immed: false */
|
/*jshint immed: false */
|
||||||
(function() {
|
(function() {
|
||||||
@ -270,11 +343,11 @@ describe("red/nodes/index", function() {
|
|||||||
}).otherwise(function(err) {
|
}).otherwise(function(err) {
|
||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it(': prevents removing a module that is unknown',function(done) {
|
it('prevents removing a module that is unknown',function(done) {
|
||||||
index.init(runtime);
|
index.init(runtime);
|
||||||
index.registerType('test', TestNode);
|
index.registerType('test-node-set','test', TestNode);
|
||||||
index.loadFlows().then(function() {
|
index.loadFlows().then(function() {
|
||||||
/*jshint immed: false */
|
/*jshint immed: false */
|
||||||
(function() {
|
(function() {
|
||||||
|
@ -153,6 +153,8 @@ describe("red/settings", function() {
|
|||||||
settings.registerNodeSettings("_http_request_", {httpRequest3:{value:"a3", exportable:true}} );
|
settings.registerNodeSettings("_http_request_", {httpRequest3:{value:"a3", exportable:true}} );
|
||||||
settings.registerNodeSettings("mQtT", {mQtTColor:{value:"purple", exportable:true}} );
|
settings.registerNodeSettings("mQtT", {mQtTColor:{value:"purple", exportable:true}} );
|
||||||
settings.registerNodeSettings("abc123", {abc123:{value:"def456", exportable:true}} );
|
settings.registerNodeSettings("abc123", {abc123:{value:"def456", exportable:true}} );
|
||||||
|
settings.registerNodeSettings("noValue", {noValueHasValue:{value:"123", exportable:true}, noValueNoValue:{exportable:true}} );
|
||||||
|
|
||||||
var safeSettings = {};
|
var safeSettings = {};
|
||||||
settings.exportNodeSettings(safeSettings);
|
settings.exportNodeSettings(safeSettings);
|
||||||
safeSettings["nodeSettings"].should.have.property("injectColor", "red");
|
safeSettings["nodeSettings"].should.have.property("injectColor", "red");
|
||||||
@ -164,15 +166,26 @@ describe("red/settings", function() {
|
|||||||
safeSettings["nodeSettings"].should.have.property("httpRequest3", "a3");
|
safeSettings["nodeSettings"].should.have.property("httpRequest3", "a3");
|
||||||
safeSettings["nodeSettings"].should.have.property("mQtTColor", "purple");
|
safeSettings["nodeSettings"].should.have.property("mQtTColor", "purple");
|
||||||
safeSettings["nodeSettings"].should.have.property("abc123", "def456");
|
safeSettings["nodeSettings"].should.have.property("abc123", "def456");
|
||||||
|
|
||||||
|
safeSettings["nodeSettings"].should.have.property("noValueHasValue", "123");
|
||||||
|
safeSettings["nodeSettings"].should.not.have.property("noValueNoValue");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prohibits registering the property whose name do not start with type name', function() {
|
it('prohibits registering the property whose name do not start with type name', function() {
|
||||||
var userSettings = {};
|
var userSettings = {};
|
||||||
settings.init(userSettings);
|
settings.init(userSettings);
|
||||||
settings.registerNodeSettings("inject", {color:{value:"red", exportable:true}} );
|
(function() {
|
||||||
settings.registerNodeSettings("_a_b_1_", {ab1Color:{value:"red", exportable:true}} );
|
settings.registerNodeSettings("inject", {color:{value:"red", exportable:true}} );
|
||||||
settings.registerNodeSettings("AB2", {AB2Color:{value:"red", exportable:true}} );
|
}).should.throw();
|
||||||
settings.registerNodeSettings("abcDef", {abcColor:{value:"red", exportable:true}} );
|
(function() {
|
||||||
|
settings.registerNodeSettings("_a_b_1_", {ab1Color:{value:"red", exportable:true}} );
|
||||||
|
}).should.throw();
|
||||||
|
(function() {
|
||||||
|
settings.registerNodeSettings("AB2", {AB2Color:{value:"red", exportable:true}} );
|
||||||
|
}).should.throw();
|
||||||
|
(function() {
|
||||||
|
settings.registerNodeSettings("abcDef", {abcColor:{value:"red", exportable:true}} );
|
||||||
|
}).should.throw();
|
||||||
var safeSettings = {};
|
var safeSettings = {};
|
||||||
settings.exportNodeSettings(safeSettings);
|
settings.exportNodeSettings(safeSettings);
|
||||||
safeSettings["nodeSettings"].should.not.have.property("color");
|
safeSettings["nodeSettings"].should.not.have.property("color");
|
||||||
|
Loading…
Reference in New Issue
Block a user