Fix function node tests use of RED.settings

This commit is contained in:
Nick O'Leary 2021-03-02 00:12:41 +00:00
parent 3d23d1de4f
commit 0566a2d9b1
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 7 additions and 11 deletions

View File

@ -18,7 +18,7 @@ var should = require("should");
var functionNode = require("nr-test-utils").require("@node-red/nodes/core/function/10-function.js");
var Context = require("nr-test-utils").require("@node-red/runtime/lib/nodes/context");
var helper = require("node-red-node-test-helper");
var RED = require("nr-test-utils").require("node-red/lib/red");
describe('function node', function() {
before(function(done) {
@ -1415,7 +1415,9 @@ describe('function node', function() {
});
describe('externalModules', function() {
afterEach(function() {
delete RED.settings.functionExternalModules;
})
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"}]},
@ -1433,9 +1435,7 @@ describe('function node', function() {
{id:"n1",type:"function",wires:[["n2"]],func:"msg.payload = os.type(); return msg;"},
{id:"n2", type:"helper"}
];
helper.settings({
functionExternalModules: true
})
RED.settings.functionExternalModules = true;
helper.load(functionNode, flow, function() {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
@ -1459,9 +1459,7 @@ describe('function node', function() {
{id:"n1",type:"function",wires:[["n2"]],func:"msg.payload = os.type(); return msg;", "libs": [{var:"os", module:"os"}]},
{id:"n2", type:"helper"}
];
helper.settings({
functionExternalModules: true
})
RED.settings.functionExternalModules = true;
helper.load(functionNode, flow, function() {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
@ -1482,9 +1480,7 @@ describe('function node', function() {
{id:"n1",type:"function",wires:[["n2"]],func:"msg.payload = os.type(); return msg;", "libs": [{var:"flow", module:"os"}]},
{id:"n2", type:"helper"}
];
helper.settings({
functionExternalModules: true
})
RED.settings.functionExternalModules = true;
helper.load(functionNode, flow, function() {
var n1 = helper.getNode("n1");
should.not.exist(n1);