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

Fix functionExternalModules tests

This commit is contained in:
Nick O'Leary 2021-03-01 21:34:37 +00:00
parent c3adc956d7
commit c9c5f7f088
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 22 additions and 1 deletions

View File

@ -479,7 +479,7 @@ module.exports = function(RED) {
RED.nodes.registerType("function",FunctionNode, { RED.nodes.registerType("function",FunctionNode, {
dynamicModuleList: "libs", dynamicModuleList: "libs",
settings: { settings: {
functionExternalModules: { value: true, exportable: true } functionExternalModules: { value: false, exportable: true }
} }
}); });
RED.library.register("functions"); RED.library.register("functions");

View File

@ -1416,11 +1416,26 @@ describe('function node', function() {
describe('externalModules', function() { describe('externalModules', function() {
it('should fail if using OS module without functionExternalModules set to true', function(done) {
var flow = [
{id:"n1",type:"function",wires:[["n2"]],func:"msg.payload = os.type(); return msg;", "libs": [{var:"os", module:"os"}]},
{id:"n2", type:"helper"}
];
helper.load(functionNode, flow, function() {
var n1 = helper.getNode("n1");
should.not.exist(n1);
done();
}).catch(err => done(err));
})
it('should fail if using OS module without it listed in libs', function(done) { it('should fail if using OS module without it listed in libs', function(done) {
var flow = [ var flow = [
{id:"n1",type:"function",wires:[["n2"]],func:"msg.payload = os.type(); return msg;"}, {id:"n1",type:"function",wires:[["n2"]],func:"msg.payload = os.type(); return msg;"},
{id:"n2", type:"helper"} {id:"n2", type:"helper"}
]; ];
helper.settings({
functionExternalModules: true
})
helper.load(functionNode, flow, function() { helper.load(functionNode, flow, function() {
var n1 = helper.getNode("n1"); var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2"); var n2 = helper.getNode("n2");
@ -1444,6 +1459,9 @@ describe('function node', function() {
{id:"n1",type:"function",wires:[["n2"]],func:"msg.payload = os.type(); return msg;", "libs": [{var:"os", module:"os"}]}, {id:"n1",type:"function",wires:[["n2"]],func:"msg.payload = os.type(); return msg;", "libs": [{var:"os", module:"os"}]},
{id:"n2", type:"helper"} {id:"n2", type:"helper"}
]; ];
helper.settings({
functionExternalModules: true
})
helper.load(functionNode, flow, function() { helper.load(functionNode, flow, function() {
var n1 = helper.getNode("n1"); var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2"); var n2 = helper.getNode("n2");
@ -1464,6 +1482,9 @@ describe('function node', function() {
{id:"n1",type:"function",wires:[["n2"]],func:"msg.payload = os.type(); return msg;", "libs": [{var:"flow", module:"os"}]}, {id:"n1",type:"function",wires:[["n2"]],func:"msg.payload = os.type(); return msg;", "libs": [{var:"flow", module:"os"}]},
{id:"n2", type:"helper"} {id:"n2", type:"helper"}
]; ];
helper.settings({
functionExternalModules: true
})
helper.load(functionNode, flow, function() { helper.load(functionNode, flow, function() {
var n1 = helper.getNode("n1"); var n1 = helper.getNode("n1");
should.not.exist(n1); should.not.exist(n1);