mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Update to latest sinon
This commit is contained in:
parent
9882582903
commit
877c463494
14
package.json
14
package.json
@ -87,14 +87,14 @@
|
||||
"grunt-cli": "~1.4.2",
|
||||
"grunt-concurrent": "3.0.0",
|
||||
"grunt-contrib-clean": "~2.0.0",
|
||||
"grunt-contrib-compress": "1.6.0",
|
||||
"grunt-contrib-compress": "2.0.0",
|
||||
"grunt-contrib-concat": "~1.0.1",
|
||||
"grunt-contrib-copy": "~1.0.0",
|
||||
"grunt-contrib-jshint": "~2.1.0",
|
||||
"grunt-contrib-uglify": "~4.0.1",
|
||||
"grunt-contrib-jshint": "3.0.0",
|
||||
"grunt-contrib-uglify": "5.0.1",
|
||||
"grunt-contrib-watch": "~1.1.0",
|
||||
"grunt-jsdoc": "2.4.1",
|
||||
"grunt-jsdoc-to-markdown": "5.0.0",
|
||||
"grunt-jsdoc-to-markdown": "6.0.0",
|
||||
"grunt-jsonlint": "2.1.3",
|
||||
"grunt-mkdir": "~1.1.0",
|
||||
"grunt-npm-command": "~0.1.2",
|
||||
@ -105,14 +105,14 @@
|
||||
"jsdoc-nr-template": "github:node-red/jsdoc-nr-template",
|
||||
"marked": "2.0.1",
|
||||
"minami": "1.2.3",
|
||||
"mocha": "^5.2.0",
|
||||
"mocha": "8.3.2",
|
||||
"node-red-node-test-helper": "^0.2.7",
|
||||
"node-sass": "^5.0.0",
|
||||
"nodemon": "2.0.7",
|
||||
"should": "13.2.3",
|
||||
"sinon": "1.17.7",
|
||||
"sinon": "10.0.1",
|
||||
"stoppable": "^1.1.0",
|
||||
"supertest": "5.0.0"
|
||||
"supertest": "6.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
|
@ -483,7 +483,7 @@ describe('trigger node', function() {
|
||||
});
|
||||
|
||||
it('should be able to return things from flow and global context variables', function(done) {
|
||||
var spy = sinon.stub(RED.util, 'evaluateNodeProperty',
|
||||
var spy = sinon.stub(RED.util, 'evaluateNodeProperty').callsFake(
|
||||
function(arg1, arg2, arg3, arg4, arg5) { if (arg5) { arg5(null, arg1) } else { return arg1; } }
|
||||
);
|
||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", op1:"foo", op1type:"flow", op2:"bar", op2type:"global", duration:"20", wires:[["n2"]] },
|
||||
@ -742,7 +742,7 @@ describe('trigger node', function() {
|
||||
|
||||
it('should be able to extend the delay', function(done) {
|
||||
this.timeout(5000); // add extra time for flake
|
||||
var spy = sinon.stub(RED.util, 'evaluateNodeProperty',
|
||||
var spy = sinon.stub(RED.util, 'evaluateNodeProperty').callsFake(
|
||||
function(arg1, arg2, arg3, arg4, arg5) { if (arg5) { arg5(null, arg1) } else { return arg1; } }
|
||||
);
|
||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", extend:"true", op1type:"flow", op1:"foo", op2:"bar", op2type:"global", duration:"100", wires:[["n2"]] },
|
||||
|
@ -53,7 +53,7 @@ describe('exec node', function() {
|
||||
it('should exec a simple command', function(done) {
|
||||
var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:false, append:"", oldrc:"false"},
|
||||
{id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}];
|
||||
var spy = sinon.stub(child_process, 'exec',
|
||||
var spy = sinon.stub(child_process, 'exec').callsFake(
|
||||
function(arg1, arg2, arg3, arg4) {
|
||||
// arg3(error,stdout,stderr);
|
||||
arg3(null,arg1,arg1.toUpperCase());
|
||||
@ -137,7 +137,7 @@ describe('exec node', function() {
|
||||
it('should exec a simple command with extra parameters', function(done) {
|
||||
var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:"payload", append:"more", oldrc:"false"},
|
||||
{id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}];
|
||||
var spy = sinon.stub(child_process, 'exec',
|
||||
var spy = sinon.stub(child_process, 'exec').callsFake(
|
||||
function(arg1, arg2, arg3, arg4) {
|
||||
//console.log(arg1);
|
||||
// arg3(error,stdout,stderr);
|
||||
@ -193,7 +193,7 @@ describe('exec node', function() {
|
||||
it('should be able to return a binary buffer', function(done) {
|
||||
var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:true, append:"more", oldrc:"false"},
|
||||
{id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}];
|
||||
var spy = sinon.stub(child_process, 'exec',
|
||||
var spy = sinon.stub(child_process, 'exec').callsFake(
|
||||
function(arg1, arg2, arg3, arg4) {
|
||||
//console.log(arg1);
|
||||
// arg3(error,stdout,stderr);
|
||||
@ -325,7 +325,7 @@ describe('exec node', function() {
|
||||
it('should return the rc for a failing command', function(done) {
|
||||
var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"error", addpay:false, append:"", oldrc:"false"},
|
||||
{id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}];
|
||||
var spy = sinon.stub(child_process, 'exec',
|
||||
var spy = sinon.stub(child_process, 'exec').callsFake(
|
||||
function(arg1, arg2, arg3, arg4) {
|
||||
//console.log(arg1);
|
||||
// arg3(error,stdout,stderr);
|
||||
@ -388,7 +388,7 @@ describe('exec node', function() {
|
||||
it('should preserve existing properties on msg object', function(done) {
|
||||
var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:false, append:"", oldrc:"false"},
|
||||
{id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}];
|
||||
var spy = sinon.stub(child_process, 'exec',
|
||||
var spy = sinon.stub(child_process, 'exec').callsFake(
|
||||
function(arg1, arg2, arg3, arg4) {
|
||||
// arg3(error,stdout,stderr);
|
||||
arg3(null,arg1,arg1.toUpperCase());
|
||||
@ -455,7 +455,7 @@ describe('exec node', function() {
|
||||
it('should preserve existing properties on msg object for a failing command', function(done) {
|
||||
var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"error", addpay:false, append:"", oldrc:"false"},
|
||||
{id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}];
|
||||
var spy = sinon.stub(child_process, 'exec',
|
||||
var spy = sinon.stub(child_process, 'exec').callsFake(
|
||||
function(arg1, arg2, arg3, arg4) {
|
||||
// arg3(error,stdout,stderr);
|
||||
arg3({code: 1},arg1,arg1.toUpperCase());
|
||||
|
@ -391,7 +391,7 @@ describe('file Nodes', function() {
|
||||
|
||||
it('should fail to write to a ro file', function(done) {
|
||||
// Stub file write so we can make writes fail
|
||||
var spy = sinon.stub(fs, 'createWriteStream', function(arg1,arg2) {
|
||||
var spy = sinon.stub(fs, 'createWriteStream').callsFake(function(arg1,arg2) {
|
||||
var ws = {};
|
||||
ws.on = function(e,d) { throw("Stub error message"); }
|
||||
ws.write = function(e,d) { }
|
||||
@ -421,7 +421,7 @@ describe('file Nodes', function() {
|
||||
|
||||
it('should fail to append to a ro file', function(done) {
|
||||
// Stub file write so we can make writes fail
|
||||
var spy = sinon.stub(fs, 'createWriteStream', function(arg1,arg2) {
|
||||
var spy = sinon.stub(fs, 'createWriteStream').callsFake(function(arg1,arg2) {
|
||||
var ws = {};
|
||||
ws.on = function(e,d) { throw("Stub error message"); }
|
||||
ws.write = function(e,d) { }
|
||||
@ -451,7 +451,7 @@ describe('file Nodes', function() {
|
||||
|
||||
it('should cope with failing to delete a file', function(done) {
|
||||
// Stub file write so we can make writes fail
|
||||
var spy = sinon.stub(fs, 'unlink', function(arg,arg2) { arg2(new Error("Stub error message")); });
|
||||
var spy = sinon.stub(fs, 'unlink').callsFake(function(arg,arg2) { arg2(new Error("Stub error message")); });
|
||||
|
||||
var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":true, "overwriteFile":"delete"}];
|
||||
helper.load(fileNode, flow, function() {
|
||||
@ -477,7 +477,7 @@ describe('file Nodes', function() {
|
||||
it('should fail to create a new directory if not asked to do so (append)', function(done) {
|
||||
// Stub file write so we can make writes fail
|
||||
var fileToTest2 = path.join(resourcesDir,"file-out-node","50-file-test-file.txt");
|
||||
//var spy = sinon.stub(fs, 'appendFile', function(arg,arg2,arg3,arg4){ arg4(new Error("Stub error message")); });
|
||||
//var spy = sinon.stub(fs, 'appendFile').callsFake(function(arg,arg2,arg3,arg4){ arg4(new Error("Stub error message")); });
|
||||
|
||||
var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest2, "appendNewline":true, "overwriteFile":false}];
|
||||
helper.load(fileNode, flow, function() {
|
||||
@ -508,7 +508,7 @@ describe('file Nodes', function() {
|
||||
}
|
||||
// Stub file write so we can make writes fail
|
||||
var fileToTest2 = path.join(resourcesDir,"file-out-node","50-file-test-file.txt");
|
||||
var spy = sinon.stub(fs, "ensureDir", function(arg1,arg2,arg3,arg4) { arg2(null); });
|
||||
var spy = sinon.stub(fs, "ensureDir").callsFake(function(arg1,arg2,arg3,arg4) { arg2(null); });
|
||||
var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest2, "appendNewline":true, "overwriteFile":false, "createDir":true}];
|
||||
helper.load(fileNode, flow, function() {
|
||||
var n1 = helper.getNode("fileNode1");
|
||||
@ -531,7 +531,7 @@ describe('file Nodes', function() {
|
||||
it('should fail to create a new directory if not asked to do so (overwrite)', function(done) {
|
||||
// Stub file write so we can make writes fail
|
||||
var fileToTest2 = path.join(resourcesDir,"file-out-node","50-file-test-file.txt");
|
||||
//var spy = sinon.stub(fs, 'appendFile', function(arg,arg2,arg3,arg4){ arg4(new Error("Stub error message")); });
|
||||
//var spy = sinon.stub(fs, 'appendFile').callsFake(function(arg,arg2,arg3,arg4){ arg4(new Error("Stub error message")); });
|
||||
|
||||
var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest2, "appendNewline":false, "overwriteFile":true}];
|
||||
helper.load(fileNode, flow, function() {
|
||||
@ -557,7 +557,7 @@ describe('file Nodes', function() {
|
||||
it('should try to create a new directory if asked to do so (overwrite)', function(done) {
|
||||
// Stub file write so we can make writes fail
|
||||
var fileToTest2 = path.join(resourcesDir,"file-out-node","50-file-test-file.txt");
|
||||
var spy = sinon.stub(fs, "ensureDir", function(arg1,arg2,arg3,arg4) { arg2(null); });
|
||||
var spy = sinon.stub(fs, "ensureDir").callsFake(function(arg1,arg2,arg3,arg4) { arg2(null); });
|
||||
|
||||
var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest2, "appendNewline":true, "overwriteFile":true, "createDir":true}];
|
||||
helper.load(fileNode, flow, function() {
|
||||
|
@ -45,35 +45,35 @@ describe("api/admin/index", function() {
|
||||
};
|
||||
before(function() {
|
||||
mockList.forEach(function(m) {
|
||||
sinon.stub(m,"init",function(){});
|
||||
sinon.stub(m,"init").callsFake(function(){});
|
||||
});
|
||||
sinon.stub(auth,"needsPermission", function(permission) {
|
||||
sinon.stub(auth,"needsPermission").callsFake(function(permission) {
|
||||
return function(req,res,next) {
|
||||
permissionChecks[permission] = (permissionChecks[permission]||0)+1;
|
||||
next();
|
||||
};
|
||||
});
|
||||
|
||||
sinon.stub(flows,"get",stubApp);
|
||||
sinon.stub(flows,"post",stubApp);
|
||||
sinon.stub(flows,"get").callsFake(stubApp);
|
||||
sinon.stub(flows,"post").callsFake(stubApp);
|
||||
|
||||
sinon.stub(flow,"get",stubApp);
|
||||
sinon.stub(flow,"post",stubApp);
|
||||
sinon.stub(flow,"delete",stubApp);
|
||||
sinon.stub(flow,"put",stubApp);
|
||||
sinon.stub(flow,"get").callsFake(stubApp);
|
||||
sinon.stub(flow,"post").callsFake(stubApp);
|
||||
sinon.stub(flow,"delete").callsFake(stubApp);
|
||||
sinon.stub(flow,"put").callsFake(stubApp);
|
||||
|
||||
sinon.stub(nodes,"getAll",stubApp);
|
||||
sinon.stub(nodes,"post",stubApp);
|
||||
sinon.stub(nodes,"getModule",stubApp);
|
||||
sinon.stub(nodes,"putModule",stubApp);
|
||||
sinon.stub(nodes,"delete",stubApp);
|
||||
sinon.stub(nodes,"getSet",stubApp);
|
||||
sinon.stub(nodes,"putSet",stubApp);
|
||||
sinon.stub(nodes,"getModuleCatalog",stubApp);
|
||||
sinon.stub(nodes,"getModuleCatalogs",stubApp);
|
||||
sinon.stub(nodes,"getAll").callsFake(stubApp);
|
||||
sinon.stub(nodes,"post").callsFake(stubApp);
|
||||
sinon.stub(nodes,"getModule").callsFake(stubApp);
|
||||
sinon.stub(nodes,"putModule").callsFake(stubApp);
|
||||
sinon.stub(nodes,"delete").callsFake(stubApp);
|
||||
sinon.stub(nodes,"getSet").callsFake(stubApp);
|
||||
sinon.stub(nodes,"putSet").callsFake(stubApp);
|
||||
sinon.stub(nodes,"getModuleCatalog").callsFake(stubApp);
|
||||
sinon.stub(nodes,"getModuleCatalogs").callsFake(stubApp);
|
||||
|
||||
sinon.stub(context,"get",stubApp);
|
||||
sinon.stub(context,"delete",stubApp);
|
||||
sinon.stub(context,"get").callsFake(stubApp);
|
||||
sinon.stub(context,"delete").callsFake(stubApp);
|
||||
});
|
||||
after(function() {
|
||||
mockList.forEach(function(m) {
|
||||
|
@ -41,7 +41,7 @@ describe("api/admin/nodes", function() {
|
||||
app.put(/\/nodes\/((@[^\/]+\/)?[^\/]+)\/([^\/]+)$/,nodes.putSet);
|
||||
app.get("/getIcons",nodes.getIcons);
|
||||
app.delete(/\/nodes\/((@[^\/]+\/)?[^\/]+)$/,nodes.delete);
|
||||
sinon.stub(apiUtil,"determineLangFromHeaders", function() {
|
||||
sinon.stub(apiUtil,"determineLangFromHeaders").callsFake(function() {
|
||||
return "en-US";
|
||||
});
|
||||
});
|
||||
|
@ -29,7 +29,7 @@ var theme = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/theme");
|
||||
|
||||
describe("api/editor/settings", function() {
|
||||
before(function() {
|
||||
sinon.stub(theme,"settings",function() { return { existing: 123, test: 456 };});
|
||||
sinon.stub(theme,"settings").callsFake(function() { return { existing: 123, test: 456 };});
|
||||
app = express();
|
||||
app.use(bodyParser.json());
|
||||
app.get("/settings",info.runtimeSettings);
|
||||
|
@ -58,7 +58,7 @@ describe("api/auth/index",function() {
|
||||
|
||||
describe("revoke", function() {
|
||||
it("revokes a token", function(done) {
|
||||
var revokeToken = sinon.stub(Tokens,"revoke",function() {
|
||||
var revokeToken = sinon.stub(Tokens,"revoke").callsFake(function() {
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
||||
@ -79,8 +79,8 @@ describe("api/auth/index",function() {
|
||||
|
||||
describe("login", function() {
|
||||
beforeEach(function() {
|
||||
sinon.stub(Tokens,"init",function(){});
|
||||
sinon.stub(Users,"init",function(){});
|
||||
sinon.stub(Tokens,"init").callsFake(function(){});
|
||||
sinon.stub(Users,"init").callsFake(function(){});
|
||||
});
|
||||
afterEach(function() {
|
||||
Tokens.init.restore();
|
||||
@ -119,8 +119,8 @@ describe("api/auth/index",function() {
|
||||
});
|
||||
describe("needsPermission", function() {
|
||||
beforeEach(function() {
|
||||
sinon.stub(Tokens,"init",function(){});
|
||||
sinon.stub(Users,"init",function(){});
|
||||
sinon.stub(Tokens,"init").callsFake(function(){});
|
||||
sinon.stub(Users,"init").callsFake(function(){});
|
||||
});
|
||||
afterEach(function() {
|
||||
Tokens.init.restore();
|
||||
@ -135,7 +135,7 @@ describe("api/auth/index",function() {
|
||||
|
||||
|
||||
it('no-ops if adminAuth not set', function(done) {
|
||||
sinon.stub(passport,"authenticate",function(scopes,opts) {
|
||||
sinon.stub(passport,"authenticate").callsFake(function(scopes,opts) {
|
||||
return function(req,res,next) {
|
||||
}
|
||||
});
|
||||
@ -147,12 +147,12 @@ describe("api/auth/index",function() {
|
||||
})
|
||||
});
|
||||
it('skips auth if req.user undefined', function(done) {
|
||||
sinon.stub(passport,"authenticate",function(scopes,opts) {
|
||||
sinon.stub(passport,"authenticate").callsFake(function(scopes,opts) {
|
||||
return function(req,res,next) {
|
||||
next();
|
||||
}
|
||||
});
|
||||
sinon.stub(Permissions,"hasPermission",function(perm) { return true });
|
||||
sinon.stub(Permissions,"hasPermission").callsFake(function(perm) { return true });
|
||||
auth.init({adminAuth:{}});
|
||||
var func = auth.needsPermission("foo");
|
||||
func({user:null},{},function() {
|
||||
@ -167,12 +167,12 @@ describe("api/auth/index",function() {
|
||||
});
|
||||
|
||||
it('passes for valid user permission', function(done) {
|
||||
sinon.stub(passport,"authenticate",function(scopes,opts) {
|
||||
sinon.stub(passport,"authenticate").callsFake(function(scopes,opts) {
|
||||
return function(req,res,next) {
|
||||
next();
|
||||
}
|
||||
});
|
||||
sinon.stub(Permissions,"hasPermission",function(perm) { return true });
|
||||
sinon.stub(Permissions,"hasPermission").callsFake(function(perm) { return true });
|
||||
auth.init({adminAuth:{}});
|
||||
var func = auth.needsPermission("foo");
|
||||
func({user:true,authInfo: { scope: "read"}},{},function() {
|
||||
@ -189,12 +189,12 @@ describe("api/auth/index",function() {
|
||||
});
|
||||
|
||||
it('rejects for invalid user permission', function(done) {
|
||||
sinon.stub(passport,"authenticate",function(scopes,opts) {
|
||||
sinon.stub(passport,"authenticate").callsFake(function(scopes,opts) {
|
||||
return function(req,res,next) {
|
||||
next();
|
||||
}
|
||||
});
|
||||
sinon.stub(Permissions,"hasPermission",function(perm) { return false });
|
||||
sinon.stub(Permissions,"hasPermission").callsFake(function(perm) { return false });
|
||||
auth.init({adminAuth:{}});
|
||||
var func = auth.needsPermission("foo");
|
||||
func({user:true,authInfo: { scope: "read"}},{
|
||||
|
@ -35,7 +35,7 @@ describe("api/auth/strategies", function() {
|
||||
});
|
||||
|
||||
it('Handles authentication failure',function(done) {
|
||||
userAuthentication = sinon.stub(Users,"authenticate",function(username,password) {
|
||||
userAuthentication = sinon.stub(Users,"authenticate").callsFake(function(username,password) {
|
||||
return Promise.resolve(null);
|
||||
});
|
||||
|
||||
@ -51,7 +51,7 @@ describe("api/auth/strategies", function() {
|
||||
});
|
||||
|
||||
it('Handles scope overreach',function(done) {
|
||||
userAuthentication = sinon.stub(Users,"authenticate",function(username,password) {
|
||||
userAuthentication = sinon.stub(Users,"authenticate").callsFake(function(username,password) {
|
||||
return Promise.resolve({username:"user",permissions:"read"});
|
||||
});
|
||||
|
||||
@ -67,11 +67,11 @@ describe("api/auth/strategies", function() {
|
||||
});
|
||||
|
||||
it('Creates new token on authentication success',function(done) {
|
||||
userAuthentication = sinon.stub(Users,"authenticate",function(username,password) {
|
||||
userAuthentication = sinon.stub(Users,"authenticate").callsFake(function(username,password) {
|
||||
return Promise.resolve({username:"user",permissions:"*"});
|
||||
});
|
||||
var tokenDetails = {};
|
||||
var tokenCreate = sinon.stub(Tokens,"create",function(username,client,scope) {
|
||||
var tokenCreate = sinon.stub(Tokens,"create").callsFake(function(username,client,scope) {
|
||||
tokenDetails.username = username;
|
||||
tokenDetails.client = client;
|
||||
tokenDetails.scope = scope;
|
||||
@ -98,7 +98,7 @@ describe("api/auth/strategies", function() {
|
||||
|
||||
describe("Anonymous Strategy", function() {
|
||||
it('Succeeds if anon user enabled',function(done) {
|
||||
var userDefault = sinon.stub(Users,"default",function() {
|
||||
var userDefault = sinon.stub(Users,"default").callsFake(function() {
|
||||
return Promise.resolve("anon");
|
||||
});
|
||||
strategies.anonymousStrategy._success = strategies.anonymousStrategy.success;
|
||||
@ -111,7 +111,7 @@ describe("api/auth/strategies", function() {
|
||||
strategies.anonymousStrategy.authenticate({});
|
||||
});
|
||||
it('Fails if anon user not enabled',function(done) {
|
||||
var userDefault = sinon.stub(Users,"default",function() {
|
||||
var userDefault = sinon.stub(Users,"default").callsFake(function() {
|
||||
return Promise.resolve(null);
|
||||
});
|
||||
strategies.anonymousStrategy._fail = strategies.anonymousStrategy.fail;
|
||||
@ -130,10 +130,10 @@ describe("api/auth/strategies", function() {
|
||||
|
||||
describe("Tokens Strategy", function() {
|
||||
it('Succeeds if tokens user enabled custom header',function(done) {
|
||||
var userTokens = sinon.stub(Users,"tokens",function(token) {
|
||||
var userTokens = sinon.stub(Users,"tokens").callsFake(function(token) {
|
||||
return Promise.resolve("tokens-"+token);
|
||||
});
|
||||
var userTokenHeader = sinon.stub(Users,"tokenHeader",function(token) {
|
||||
var userTokenHeader = sinon.stub(Users,"tokenHeader").callsFake(function(token) {
|
||||
return "x-test-token";
|
||||
});
|
||||
strategies.tokensStrategy._success = strategies.tokensStrategy.success;
|
||||
@ -146,10 +146,10 @@ describe("api/auth/strategies", function() {
|
||||
strategies.tokensStrategy.authenticate({headers:{"x-test-token":"1234"}});
|
||||
});
|
||||
it('Succeeds if tokens user enabled default header',function(done) {
|
||||
var userTokens = sinon.stub(Users,"tokens",function(token) {
|
||||
var userTokens = sinon.stub(Users,"tokens").callsFake(function(token) {
|
||||
return Promise.resolve("tokens-"+token);
|
||||
});
|
||||
var userTokenHeader = sinon.stub(Users,"tokenHeader",function(token) {
|
||||
var userTokenHeader = sinon.stub(Users,"tokenHeader").callsFake(function(token) {
|
||||
return "authorization";
|
||||
});
|
||||
strategies.tokensStrategy._success = strategies.tokensStrategy.success;
|
||||
@ -162,10 +162,10 @@ describe("api/auth/strategies", function() {
|
||||
strategies.tokensStrategy.authenticate({headers:{"authorization":"Bearer 1234"}});
|
||||
});
|
||||
it('Fails if tokens user not enabled',function(done) {
|
||||
var userTokens = sinon.stub(Users,"tokens",function() {
|
||||
var userTokens = sinon.stub(Users,"tokens").callsFake(function() {
|
||||
return Promise.resolve(null);
|
||||
});
|
||||
var userTokenHeader = sinon.stub(Users,"tokenHeader",function(token) {
|
||||
var userTokenHeader = sinon.stub(Users,"tokenHeader").callsFake(function(token) {
|
||||
return "authorization";
|
||||
});
|
||||
strategies.tokensStrategy._fail = strategies.tokensStrategy.fail;
|
||||
@ -185,7 +185,7 @@ describe("api/auth/strategies", function() {
|
||||
|
||||
describe("Bearer Strategy", function() {
|
||||
it('Rejects invalid token',function(done) {
|
||||
var getToken = sinon.stub(Tokens,"get",function(token) {
|
||||
var getToken = sinon.stub(Tokens,"get").callsFake(function(token) {
|
||||
return Promise.resolve(null);
|
||||
});
|
||||
|
||||
@ -202,10 +202,10 @@ describe("api/auth/strategies", function() {
|
||||
});
|
||||
});
|
||||
it('Accepts valid token',function(done) {
|
||||
var getToken = sinon.stub(Tokens,"get",function(token) {
|
||||
var getToken = sinon.stub(Tokens,"get").callsFake(function(token) {
|
||||
return Promise.resolve({user:"user",scope:"scope"});
|
||||
});
|
||||
var getUser = sinon.stub(Users,"get",function(username) {
|
||||
var getUser = sinon.stub(Users,"get").callsFake(function(username) {
|
||||
return Promise.resolve("aUser");
|
||||
});
|
||||
|
||||
@ -224,10 +224,10 @@ describe("api/auth/strategies", function() {
|
||||
});
|
||||
});
|
||||
it('Fail if no user for token',function(done) {
|
||||
var getToken = sinon.stub(Tokens,"get",function(token) {
|
||||
var getToken = sinon.stub(Tokens,"get").callsFake(function(token) {
|
||||
return Promise.resolve({user:"user",scope:"scope"});
|
||||
});
|
||||
var getUser = sinon.stub(Users,"get",function(username) {
|
||||
var getUser = sinon.stub(Users,"get").callsFake(function(username) {
|
||||
return Promise.resolve(null);
|
||||
});
|
||||
|
||||
@ -250,7 +250,7 @@ describe("api/auth/strategies", function() {
|
||||
describe("Client Password Strategy", function() {
|
||||
it('Accepts valid client',function(done) {
|
||||
var testClient = {id:"node-red-editor",secret:"not_available"};
|
||||
var getClient = sinon.stub(Clients,"get",function(client) {
|
||||
var getClient = sinon.stub(Clients,"get").callsFake(function(client) {
|
||||
return Promise.resolve(testClient);
|
||||
});
|
||||
|
||||
@ -268,7 +268,7 @@ describe("api/auth/strategies", function() {
|
||||
});
|
||||
it('Rejects invalid client secret',function(done) {
|
||||
var testClient = {id:"node-red-editor",secret:"not_available"};
|
||||
var getClient = sinon.stub(Clients,"get",function(client) {
|
||||
var getClient = sinon.stub(Clients,"get").callsFake(function(client) {
|
||||
return Promise.resolve(testClient);
|
||||
});
|
||||
|
||||
@ -285,7 +285,7 @@ describe("api/auth/strategies", function() {
|
||||
});
|
||||
});
|
||||
it('Rejects invalid client id',function(done) {
|
||||
var getClient = sinon.stub(Clients,"get",function(client) {
|
||||
var getClient = sinon.stub(Clients,"get").callsFake(function(client) {
|
||||
return Promise.resolve(null);
|
||||
});
|
||||
strategies.clientPasswordStrategy("invalid_id","invalid_secret",function(err,client) {
|
||||
@ -303,7 +303,7 @@ describe("api/auth/strategies", function() {
|
||||
|
||||
var userAuthentication;
|
||||
it('Blocks after 5 failures',function(done) {
|
||||
userAuthentication = sinon.stub(Users,"authenticate",function(username,password) {
|
||||
userAuthentication = sinon.stub(Users,"authenticate").callsFake(function(username,password) {
|
||||
return Promise.resolve(null);
|
||||
});
|
||||
for (var z=0; z<5; z++) {
|
||||
|
@ -58,7 +58,7 @@ describe("api/editor/comms", function() {
|
||||
var url;
|
||||
var port;
|
||||
before(function(done) {
|
||||
sinon.stub(Users,"default",function() { return Promise.resolve(null);});
|
||||
sinon.stub(Users,"default").callsFake(function() { return Promise.resolve(null);});
|
||||
server = stoppable(http.createServer(function(req,res){app(req,res)}));
|
||||
comms.init(server, {}, {comms: mockComms});
|
||||
server.listen(listenPort, address);
|
||||
@ -126,7 +126,7 @@ describe("api/editor/comms", function() {
|
||||
var url;
|
||||
var port;
|
||||
before(function(done) {
|
||||
sinon.stub(Users,"default",function() { return Promise.resolve(null);});
|
||||
sinon.stub(Users,"default").callsFake(function() { return Promise.resolve(null);});
|
||||
server = stoppable(http.createServer(function(req,res){app(req,res)}));
|
||||
comms.init(server, {disableEditor:true}, {comms: mockComms});
|
||||
server.listen(listenPort, address);
|
||||
@ -164,7 +164,7 @@ describe("api/editor/comms", function() {
|
||||
var url;
|
||||
var port;
|
||||
before(function(done) {
|
||||
sinon.stub(Users,"default",function() { return Promise.resolve(null);});
|
||||
sinon.stub(Users,"default").callsFake(function() { return Promise.resolve(null);});
|
||||
server = stoppable(http.createServer(function(req,res){app(req,res)}));
|
||||
comms.init(server, {httpAdminRoot:"/adminPath"}, {comms: mockComms});
|
||||
server.listen(listenPort, address);
|
||||
@ -202,7 +202,7 @@ describe("api/editor/comms", function() {
|
||||
var url;
|
||||
var port;
|
||||
before(function(done) {
|
||||
sinon.stub(Users,"default",function() { return Promise.resolve(null);});
|
||||
sinon.stub(Users,"default").callsFake(function() { return Promise.resolve(null);});
|
||||
server = stoppable(http.createServer(function(req,res){app(req,res)}));
|
||||
comms.init(server, {httpAdminRoot:"/adminPath/"}, {comms: mockComms});
|
||||
server.listen(listenPort, address);
|
||||
@ -240,7 +240,7 @@ describe("api/editor/comms", function() {
|
||||
var url;
|
||||
var port;
|
||||
before(function(done) {
|
||||
sinon.stub(Users,"default",function() { return Promise.resolve(null);});
|
||||
sinon.stub(Users,"default").callsFake(function() { return Promise.resolve(null);});
|
||||
server = stoppable(http.createServer(function(req,res){app(req,res)}));
|
||||
comms.init(server, {httpAdminRoot:"adminPath"}, {comms: mockComms});
|
||||
server.listen(listenPort, address);
|
||||
@ -278,7 +278,7 @@ describe("api/editor/comms", function() {
|
||||
var url;
|
||||
var port;
|
||||
before(function(done) {
|
||||
sinon.stub(Users,"default",function() { return Promise.resolve(null);});
|
||||
sinon.stub(Users,"default").callsFake(function() { return Promise.resolve(null);});
|
||||
server = stoppable(http.createServer(function(req,res){app(req,res)}));
|
||||
comms.init(server, {webSocketKeepAliveTime: 100}, {comms: mockComms});
|
||||
server.listen(listenPort, address);
|
||||
@ -344,22 +344,22 @@ describe("api/editor/comms", function() {
|
||||
var getToken;
|
||||
var getUserToken;
|
||||
before(function(done) {
|
||||
getDefaultUser = sinon.stub(Users,"default",function() { return Promise.resolve(null);});
|
||||
getUser = sinon.stub(Users,"get", function(username) {
|
||||
getDefaultUser = sinon.stub(Users,"default").callsFake(function() { return Promise.resolve(null);});
|
||||
getUser = sinon.stub(Users,"get").callsFake(function(username) {
|
||||
if (username == "fred") {
|
||||
return Promise.resolve({permissions:"read"});
|
||||
} else {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
});
|
||||
getUserToken = sinon.stub(Users,"tokens", function(token) {
|
||||
getUserToken = sinon.stub(Users,"tokens").callsFake(function(token) {
|
||||
if (token == "abcde") {
|
||||
return Promise.resolve({user:"wilma", permissions:"*"})
|
||||
} else {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
});
|
||||
getToken = sinon.stub(Tokens,"get",function(token) {
|
||||
getToken = sinon.stub(Tokens,"get").callsFake(function(token) {
|
||||
if (token == "1234") {
|
||||
return Promise.resolve({user:"fred",scope:["*"]});
|
||||
} else if (token == "5678") {
|
||||
@ -483,7 +483,7 @@ describe("api/editor/comms", function() {
|
||||
var port;
|
||||
var getDefaultUser;
|
||||
before(function(done) {
|
||||
getDefaultUser = sinon.stub(Users,"default",function() { return Promise.resolve({permissions:"read"});});
|
||||
getDefaultUser = sinon.stub(Users,"default").callsFake(function() { return Promise.resolve({permissions:"read"});});
|
||||
server = stoppable(http.createServer(function(req,res){app(req,res)}));
|
||||
comms.init(server, {adminAuth:{}}, {comms: mockComms});
|
||||
server.listen(listenPort, address);
|
||||
|
@ -32,8 +32,8 @@ describe("api/editor/index", function() {
|
||||
var app;
|
||||
describe("disabled the editor", function() {
|
||||
beforeEach(function() {
|
||||
sinon.stub(comms,'init', function(){});
|
||||
sinon.stub(info,'init', function(){});
|
||||
sinon.stub(comms,'init').callsFake(function(){});
|
||||
sinon.stub(info,'init').callsFake(function(){});
|
||||
});
|
||||
afterEach(function() {
|
||||
comms.init.restore();
|
||||
@ -54,13 +54,13 @@ describe("api/editor/index", function() {
|
||||
var errors = [];
|
||||
var session_data = {};
|
||||
before(function() {
|
||||
sinon.stub(auth,'needsPermission',function(permission) {
|
||||
sinon.stub(auth,'needsPermission').callsFake(function(permission) {
|
||||
return function(req,res,next) { next(); }
|
||||
});
|
||||
mockList.forEach(function(m) {
|
||||
sinon.stub(NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/"+m),"init",function(){});
|
||||
sinon.stub(NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/"+m),"init").callsFake(function(){});
|
||||
});
|
||||
sinon.stub(NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/theme"),"app",function(){ return express()});
|
||||
sinon.stub(NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/theme"),"app").callsFake(function(){ return express()});
|
||||
});
|
||||
after(function() {
|
||||
mockList.forEach(function(m) {
|
||||
@ -72,7 +72,7 @@ describe("api/editor/index", function() {
|
||||
});
|
||||
|
||||
before(function() {
|
||||
sinon.stub(log,"error",function(err) { errors.push(err)})
|
||||
sinon.stub(log,"error").callsFake(function(err) { errors.push(err)})
|
||||
app = editorApi.init({},{httpNodeRoot:true, httpAdminRoot: true,disableEditor:false,exportNodeSettings:function(){}},{
|
||||
isStarted: () => Promise.resolve(isStarted)
|
||||
});
|
||||
|
@ -50,9 +50,9 @@ describe("api/editor/locales", function() {
|
||||
locales.init({});
|
||||
|
||||
// bit of a mess of internal workings
|
||||
sinon.stub(i18n.i,'changeLanguage',function(lang,callback) { if (callback) {callback();}});
|
||||
sinon.stub(i18n.i,'changeLanguage').callsFake(function(lang,callback) { if (callback) {callback();}});
|
||||
if (i18n.i.getResourceBundle) {
|
||||
sinon.stub(i18n.i,'getResourceBundle',function(lang, namespace) {return {namespace:namespace, lang:lang};});
|
||||
sinon.stub(i18n.i,'getResourceBundle').callsFake(function(lang, namespace) {return {namespace:namespace, lang:lang};});
|
||||
} else {
|
||||
// If i18n.init has not been called, then getResourceBundle isn't
|
||||
// defined - so hardcode a stub
|
||||
@ -121,7 +121,7 @@ describe("api/editor/locales", function() {
|
||||
// var app;
|
||||
// before(function() {
|
||||
// // bit of a mess of internal workings
|
||||
// sinon.stub(i18n,'catalog',function(namespace, lang) {
|
||||
// sinon.stub(i18n,'catalog').callsFake(function(namespace, lang) {
|
||||
// return {
|
||||
// "node-red": "should not return",
|
||||
// "test-module-a-id": "test-module-a-catalog",
|
||||
|
@ -29,7 +29,7 @@ var theme = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/theme");
|
||||
|
||||
describe("api/editor/settings", function() {
|
||||
before(function() {
|
||||
sinon.stub(theme,"settings",function() { return { existing: 123, test: 456 };});
|
||||
sinon.stub(theme,"settings").callsFake(function() { return { existing: 123, test: 456 };});
|
||||
app = express();
|
||||
app.use(bodyParser.json());
|
||||
app.get("/settings/user",function(req,res,next) {req.user = "fred"; next()}, info.userSettings);
|
||||
|
@ -27,7 +27,7 @@ var theme = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/theme");
|
||||
|
||||
describe("api/editor/theme", function () {
|
||||
beforeEach(function () {
|
||||
sinon.stub(fs, "statSync", function () { return true; });
|
||||
sinon.stub(fs, "statSync").callsFake(function () { return true; });
|
||||
});
|
||||
afterEach(function () {
|
||||
theme.init({settings: {}});
|
||||
|
@ -31,18 +31,18 @@ var apiAdmin = NR_TEST_UTILS.require("@node-red/editor-api/lib/admin");
|
||||
|
||||
describe("api/index", function() {
|
||||
var beforeEach = function() {
|
||||
sinon.stub(apiAuth,"init",function(){});
|
||||
sinon.stub(apiEditor,"init",function(){
|
||||
sinon.stub(apiAuth,"init").callsFake(function(){});
|
||||
sinon.stub(apiEditor,"init").callsFake(function(){
|
||||
var app = express();
|
||||
app.get("/editor",function(req,res) { res.status(200).end(); });
|
||||
return app;
|
||||
});
|
||||
sinon.stub(apiAdmin,"init",function(){
|
||||
sinon.stub(apiAdmin,"init").callsFake(function(){
|
||||
var app = express();
|
||||
app.get("/admin",function(req,res) { res.status(200).end(); });
|
||||
return app;
|
||||
});
|
||||
sinon.stub(apiAuth,"login",function(req,res){
|
||||
sinon.stub(apiAuth,"login").callsFake(function(req,res){
|
||||
res.status(200).end();
|
||||
});
|
||||
};
|
||||
@ -115,7 +115,7 @@ describe("api/index", function() {
|
||||
describe('initialises api with authentication enabled', function(done) {
|
||||
|
||||
it('enables an oauth/openID based authentication mechanism',function(done) {
|
||||
const stub = sinon.stub(apiAuth, 'genericStrategy', function(){});
|
||||
const stub = sinon.stub(apiAuth, 'genericStrategy').callsFake(function(){});
|
||||
const adminAuth = { type: 'strategy', strategy: {} }
|
||||
api.init({ httpAdminRoot: true, adminAuth },{},{},{});
|
||||
should(stub.called).be.ok();
|
||||
@ -159,7 +159,7 @@ describe("api/index", function() {
|
||||
describe('editor start', function (done) {
|
||||
|
||||
it('cannot be started when editor is disabled', function (done) {
|
||||
const stub = sinon.stub(apiEditor, 'start', function () {
|
||||
const stub = sinon.stub(apiEditor, 'start').callsFake(function () {
|
||||
return Promise.resolve(true);
|
||||
});
|
||||
api.init({ httpAdminRoot: true, disableEditor: true }, {}, {}, {});
|
||||
|
@ -33,8 +33,8 @@ describe("api/util", function() {
|
||||
var app;
|
||||
before(function() {
|
||||
app = express();
|
||||
sinon.stub(log,'error',function(msg) {loggedError = msg;});
|
||||
sinon.stub(log,'audit',function(event) {loggedEvent = event;});
|
||||
sinon.stub(log,'error').callsFake(function(msg) {loggedError = msg;});
|
||||
sinon.stub(log,'audit').callsFake(function(event) {loggedEvent = event;});
|
||||
app.get("/tooLarge", function(req,res) {
|
||||
var err = new Error();
|
||||
err.message = "request entity too large";
|
||||
|
@ -44,7 +44,7 @@ describe("externalModules api", function() {
|
||||
})
|
||||
describe("checkFlowDependencies", function() {
|
||||
beforeEach(function() {
|
||||
sinon.stub(exec,"run", async function(cmd, args, options) {
|
||||
sinon.stub(exec,"run").callsFake(async function(cmd, args, options) {
|
||||
let error;
|
||||
if (args[1] === "moduleNotFound") {
|
||||
error = new Error();
|
||||
|
@ -49,10 +49,10 @@ describe('red/registry/index', function() {
|
||||
|
||||
describe('#addModule', function() {
|
||||
it('loads the module and returns its info', function(done) {
|
||||
stubs.push(sinon.stub(loader,"addModule",function(module) {
|
||||
stubs.push(sinon.stub(loader,"addModule").callsFake(function(module) {
|
||||
return Promise.resolve();
|
||||
}));
|
||||
stubs.push(sinon.stub(typeRegistry,"getModuleInfo", function(module) {
|
||||
stubs.push(sinon.stub(typeRegistry,"getModuleInfo").callsFake(function(module) {
|
||||
return "info";
|
||||
}));
|
||||
registry.addModule("foo").then(function(info) {
|
||||
@ -61,10 +61,10 @@ describe('red/registry/index', function() {
|
||||
}).catch(function(err) { done(err); });
|
||||
});
|
||||
it('rejects if loader rejects', function(done) {
|
||||
stubs.push(sinon.stub(loader,"addModule",function(module) {
|
||||
stubs.push(sinon.stub(loader,"addModule").callsFake(function(module) {
|
||||
return Promise.reject("error");
|
||||
}));
|
||||
stubs.push(sinon.stub(typeRegistry,"getModuleInfo", function(module) {
|
||||
stubs.push(sinon.stub(typeRegistry,"getModuleInfo").callsFake(function(module) {
|
||||
return "info";
|
||||
}));
|
||||
registry.addModule("foo").then(function(info) {
|
||||
@ -78,10 +78,10 @@ describe('red/registry/index', function() {
|
||||
|
||||
describe('#enableNode',function() {
|
||||
it('enables a node set',function(done) {
|
||||
stubs.push(sinon.stub(typeRegistry,"enableNodeSet",function() {
|
||||
stubs.push(sinon.stub(typeRegistry,"enableNodeSet").callsFake(function() {
|
||||
return Promise.resolve();
|
||||
}));
|
||||
stubs.push(sinon.stub(typeRegistry,"getNodeInfo", function() {
|
||||
stubs.push(sinon.stub(typeRegistry,"getNodeInfo").callsFake(function() {
|
||||
return {id:"node-set",loaded:true};
|
||||
}));
|
||||
registry.enableNode("node-set").then(function(ns) {
|
||||
@ -92,7 +92,7 @@ describe('red/registry/index', function() {
|
||||
});
|
||||
|
||||
it('rejects if node unknown',function() {
|
||||
stubs.push(sinon.stub(typeRegistry,"enableNodeSet",function() {
|
||||
stubs.push(sinon.stub(typeRegistry,"enableNodeSet").callsFake(function() {
|
||||
throw new Error('failure');
|
||||
}));
|
||||
/*jshint immed: false */
|
||||
@ -102,15 +102,15 @@ describe('red/registry/index', function() {
|
||||
});
|
||||
|
||||
it('triggers a node load',function(done) {
|
||||
stubs.push(sinon.stub(typeRegistry,"enableNodeSet",function() {
|
||||
stubs.push(sinon.stub(typeRegistry,"enableNodeSet").callsFake(function() {
|
||||
return Promise.resolve();
|
||||
}));
|
||||
var calls = 0;
|
||||
stubs.push(sinon.stub(typeRegistry,"getNodeInfo", function() {
|
||||
stubs.push(sinon.stub(typeRegistry,"getNodeInfo").callsFake(function() {
|
||||
// loaded=false on first call, true on subsequent
|
||||
return {id:"node-set",loaded:(calls++>0)};
|
||||
}));
|
||||
stubs.push(sinon.stub(loader,"loadNodeSet",function(){return Promise.resolve();}));
|
||||
stubs.push(sinon.stub(loader,"loadNodeSet").callsFake(function(){return Promise.resolve();}));
|
||||
stubs.push(sinon.stub(typeRegistry,"getFullNodeInfo"));
|
||||
|
||||
registry.enableNode("node-set").then(function(ns) {
|
||||
|
@ -42,7 +42,7 @@ describe('nodes/registry/installer', function() {
|
||||
var execResponse;
|
||||
|
||||
beforeEach(function() {
|
||||
sinon.stub(exec,"run", () => execResponse || Promise.resolve(""))
|
||||
sinon.stub(exec,"run").callsFake(() => execResponse || Promise.resolve(""))
|
||||
installer.init({})
|
||||
});
|
||||
|
||||
@ -118,7 +118,7 @@ describe('nodes/registry/installer', function() {
|
||||
var p = Promise.reject(res);
|
||||
p.catch((err)=>{});
|
||||
execResponse = p;
|
||||
sinon.stub(typeRegistry,"getModuleInfo", function() {
|
||||
sinon.stub(typeRegistry,"getModuleInfo").callsFake(function() {
|
||||
return {
|
||||
version: "0.1.1"
|
||||
}
|
||||
@ -129,7 +129,7 @@ describe('nodes/registry/installer', function() {
|
||||
}).catch(done);
|
||||
});
|
||||
it("rejects when update requested to existing version", function(done) {
|
||||
sinon.stub(typeRegistry,"getModuleInfo", function() {
|
||||
sinon.stub(typeRegistry,"getModuleInfo").callsFake(function() {
|
||||
return {
|
||||
user: true,
|
||||
version: "0.1.1"
|
||||
@ -141,7 +141,7 @@ describe('nodes/registry/installer', function() {
|
||||
}).catch(done);
|
||||
});
|
||||
it("rejects when update requested to existing version and url", function(done) {
|
||||
sinon.stub(typeRegistry,"getModuleInfo", function() {
|
||||
sinon.stub(typeRegistry,"getModuleInfo").callsFake(function() {
|
||||
return {
|
||||
user: true,
|
||||
version: "0.1.1"
|
||||
@ -180,7 +180,7 @@ describe('nodes/registry/installer', function() {
|
||||
p.catch((err)=>{});
|
||||
execResponse = p;
|
||||
|
||||
var addModule = sinon.stub(registry,"addModule",function(md) {
|
||||
var addModule = sinon.stub(registry,"addModule").callsFake(function(md) {
|
||||
return Promise.resolve(nodeInfo);
|
||||
});
|
||||
|
||||
@ -211,7 +211,7 @@ describe('nodes/registry/installer', function() {
|
||||
});
|
||||
it("succeeds when path is valid node-red module", function(done) {
|
||||
var nodeInfo = {nodes:{module:"foo",types:["a"]}};
|
||||
var addModule = sinon.stub(registry,"addModule",function(md) {
|
||||
var addModule = sinon.stub(registry,"addModule").callsFake(function(md) {
|
||||
return Promise.resolve(nodeInfo);
|
||||
});
|
||||
var resourcesDir = path.resolve(path.join(__dirname,"resources","local","TestNodeModule","node_modules","TestNodeModule"));
|
||||
@ -241,7 +241,7 @@ describe('nodes/registry/installer', function() {
|
||||
p.catch((err)=>{});
|
||||
execResponse = p;
|
||||
|
||||
var addModule = sinon.stub(registry,"addModule",function(md) {
|
||||
var addModule = sinon.stub(registry,"addModule").callsFake(function(md) {
|
||||
return Promise.resolve(nodeInfo);
|
||||
});
|
||||
|
||||
@ -267,7 +267,7 @@ describe('nodes/registry/installer', function() {
|
||||
|
||||
it("rejects with generic error", function(done) {
|
||||
var nodeInfo = [{module:"foo",types:["a"]}];
|
||||
var removeModule = sinon.stub(registry,"removeModule",function(md) {
|
||||
var removeModule = sinon.stub(registry,"removeModule").callsFake(function(md) {
|
||||
return Promise.resolve(nodeInfo);
|
||||
});
|
||||
var res = {
|
||||
@ -288,10 +288,10 @@ describe('nodes/registry/installer', function() {
|
||||
});
|
||||
it("succeeds when module is found", function(done) {
|
||||
var nodeInfo = [{module:"foo",types:["a"]}];
|
||||
var removeModule = sinon.stub(typeRegistry,"removeModule",function(md) {
|
||||
var removeModule = sinon.stub(typeRegistry,"removeModule").callsFake(function(md) {
|
||||
return nodeInfo;
|
||||
});
|
||||
var getModuleInfo = sinon.stub(registry,"getModuleInfo",function(md) {
|
||||
var getModuleInfo = sinon.stub(registry,"getModuleInfo").callsFake(function(md) {
|
||||
return {nodes:[]};
|
||||
});
|
||||
var res = {
|
||||
@ -303,7 +303,7 @@ describe('nodes/registry/installer', function() {
|
||||
p.catch((err)=>{});
|
||||
execResponse = p;
|
||||
|
||||
sinon.stub(fs,"statSync", function(fn) { return {}; });
|
||||
sinon.stub(fs,"statSync").callsFake(function(fn) { return {}; });
|
||||
|
||||
installer.uninstallModule("this_wont_exist").then(function(info) {
|
||||
info.should.eql(nodeInfo);
|
||||
|
@ -46,8 +46,8 @@ describe("red/nodes/registry/loader",function() {
|
||||
|
||||
describe("#load",function() {
|
||||
it("load empty set without settings available", function(done) {
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles", function(){ return {};}));
|
||||
stubs.push(sinon.stub(registry,"saveNodeList", function(){ return {};}));
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles").callsFake(function(){ return {};}));
|
||||
stubs.push(sinon.stub(registry,"saveNodeList").callsFake(function(){ return {};}));
|
||||
loader.init({nodes:nodes,log:{info:function(){},_:function(){}},settings:{available:function(){return false;}}});
|
||||
loader.load(true).then(function() {
|
||||
localfilesystem.getNodeFiles.called.should.be.true();
|
||||
@ -57,8 +57,8 @@ describe("red/nodes/registry/loader",function() {
|
||||
})
|
||||
});
|
||||
it("load empty set with settings available triggers registery save", function(done) {
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles", function(){ return {};}));
|
||||
stubs.push(sinon.stub(registry,"saveNodeList", function(){ return {};}));
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles").callsFake(function(){ return {};}));
|
||||
stubs.push(sinon.stub(registry,"saveNodeList").callsFake(function(){ return {};}));
|
||||
loader.init({nodes:nodes,log:{info:function(){},_:function(){}},settings:{available:function(){return true;}}});
|
||||
loader.load(true).then(function() {
|
||||
registry.saveNodeList.called.should.be.true();
|
||||
@ -69,7 +69,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
});
|
||||
|
||||
it("load core node files scanned by lfs - single node single file", function(done) {
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles", function(){
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles").callsFake(function(){
|
||||
var result = {};
|
||||
result["node-red"] = {
|
||||
"name": "node-red",
|
||||
@ -85,10 +85,10 @@ describe("red/nodes/registry/loader",function() {
|
||||
return result;
|
||||
}));
|
||||
|
||||
stubs.push(sinon.stub(registry,"saveNodeList", function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"addModule", function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"saveNodeList").callsFake(function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"addModule").callsFake(function(){ return }));
|
||||
// This module isn't already loaded
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo", function(){ return null; }));
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo").callsFake(function(){ return null; }));
|
||||
|
||||
stubs.push(sinon.stub(nodes,"registerType"));
|
||||
loader.init({nodes:nodes,log:{info:function(){},_:function(){}},settings:{available:function(){return true;}}});
|
||||
@ -126,7 +126,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
});
|
||||
|
||||
it("load core node files scanned by lfs - ignore html if disableEditor true", function(done) {
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles", function(){
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles").callsFake(function(){
|
||||
var result = {};
|
||||
result["node-red"] = {
|
||||
"name": "node-red",
|
||||
@ -142,10 +142,10 @@ describe("red/nodes/registry/loader",function() {
|
||||
return result;
|
||||
}));
|
||||
|
||||
stubs.push(sinon.stub(registry,"saveNodeList", function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"addModule", function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"saveNodeList").callsFake(function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"addModule").callsFake(function(){ return }));
|
||||
// This module isn't already loaded
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo", function(){ return null; }));
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo").callsFake(function(){ return null; }));
|
||||
|
||||
stubs.push(sinon.stub(nodes,"registerType"));
|
||||
loader.init({nodes:nodes,log:{info:function(){},_:function(){}},settings:{disableEditor: true, available:function(){return true;}}});
|
||||
@ -190,7 +190,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
});
|
||||
|
||||
it("load core node files scanned by lfs - multiple nodes single file", function(done) {
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles", function(){
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles").callsFake(function(){
|
||||
var result = {};
|
||||
result["node-red"] = {
|
||||
"name": "node-red",
|
||||
@ -206,10 +206,10 @@ describe("red/nodes/registry/loader",function() {
|
||||
return result;
|
||||
}));
|
||||
|
||||
stubs.push(sinon.stub(registry,"saveNodeList", function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"addModule", function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"saveNodeList").callsFake(function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"addModule").callsFake(function(){ return }));
|
||||
// This module isn't already loaded
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo", function(){ return null; }));
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo").callsFake(function(){ return null; }));
|
||||
stubs.push(sinon.stub(nodes,"registerType"));
|
||||
loader.init({nodes:nodes,log:{info:function(){},_:function(){}},settings:{available:function(){return true;}}});
|
||||
loader.load().then(function(result) {
|
||||
@ -250,7 +250,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
|
||||
|
||||
it("load core node files scanned by lfs - node with promise", function(done) {
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles", function(){
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles").callsFake(function(){
|
||||
var result = {};
|
||||
result["node-red"] = {
|
||||
"name": "node-red",
|
||||
@ -266,10 +266,10 @@ describe("red/nodes/registry/loader",function() {
|
||||
return result;
|
||||
}));
|
||||
|
||||
stubs.push(sinon.stub(registry,"saveNodeList", function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"addModule", function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"saveNodeList").callsFake(function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"addModule").callsFake(function(){ return }));
|
||||
// This module isn't already loaded
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo", function(){ return null; }));
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo").callsFake(function(){ return null; }));
|
||||
|
||||
stubs.push(sinon.stub(nodes,"registerType"));
|
||||
loader.init({nodes:nodes,log:{info:function(){},_:function(){}},settings:{available:function(){return true;}}});
|
||||
@ -308,7 +308,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
|
||||
|
||||
it("load core node files scanned by lfs - node with rejecting promise", function(done) {
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles", function(){
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles").callsFake(function(){
|
||||
var result = {};
|
||||
result["node-red"] = {
|
||||
"name": "node-red",
|
||||
@ -324,10 +324,10 @@ describe("red/nodes/registry/loader",function() {
|
||||
return result;
|
||||
}));
|
||||
|
||||
stubs.push(sinon.stub(registry,"saveNodeList", function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"addModule", function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"saveNodeList").callsFake(function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"addModule").callsFake(function(){ return }));
|
||||
// This module isn't already loaded
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo", function(){ return null; }));
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo").callsFake(function(){ return null; }));
|
||||
|
||||
stubs.push(sinon.stub(nodes,"registerType"));
|
||||
loader.init({nodes:nodes,log:{info:function(){},_:function(){}},settings:{available:function(){return true;}}});
|
||||
@ -362,7 +362,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
});
|
||||
|
||||
it("load core node files scanned by lfs - missing file", function(done) {
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles", function(){
|
||||
stubs.push(sinon.stub(localfilesystem,"getNodeFiles").callsFake(function(){
|
||||
var result = {};
|
||||
result["node-red"] = {
|
||||
"name": "node-red",
|
||||
@ -378,10 +378,10 @@ describe("red/nodes/registry/loader",function() {
|
||||
return result;
|
||||
}));
|
||||
|
||||
stubs.push(sinon.stub(registry,"saveNodeList", function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"addModule", function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"saveNodeList").callsFake(function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"addModule").callsFake(function(){ return }));
|
||||
// This module isn't already loaded
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo", function(){ return null; }));
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo").callsFake(function(){ return null; }));
|
||||
|
||||
stubs.push(sinon.stub(nodes,"registerType"));
|
||||
loader.init({nodes:nodes,log:{info:function(){},_:function(){}},settings:{available:function(){return true;}}});
|
||||
@ -416,7 +416,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
|
||||
// it("load core node files scanned by lfs - missing html file", function(done) {
|
||||
// // This is now an okay situation
|
||||
// stubs.push(sinon.stub(localfilesystem,"getNodeFiles", function(){
|
||||
// stubs.push(sinon.stub(localfilesystem,"getNodeFiles").callsFake(function(){
|
||||
// var result = {};
|
||||
// result["node-red"] = {
|
||||
// "name": "node-red",
|
||||
@ -432,10 +432,10 @@ describe("red/nodes/registry/loader",function() {
|
||||
// return result;
|
||||
// }));
|
||||
//
|
||||
// stubs.push(sinon.stub(registry,"saveNodeList", function(){ return }));
|
||||
// stubs.push(sinon.stub(registry,"addModule", function(){ return }));
|
||||
// stubs.push(sinon.stub(registry,"saveNodeList").callsFake(function(){ return }));
|
||||
// stubs.push(sinon.stub(registry,"addModule").callsFake(function(){ return }));
|
||||
// // This module isn't already loaded
|
||||
// stubs.push(sinon.stub(registry,"getNodeInfo", function(){ return null; }));
|
||||
// stubs.push(sinon.stub(registry,"getNodeInfo").callsFake(function(){ return null; }));
|
||||
//
|
||||
// stubs.push(sinon.stub(nodes,"registerType"));
|
||||
// loader.init({nodes:nodes,log:{info:function(){},_:function(){}},settings:{available:function(){return true;}}});
|
||||
@ -481,7 +481,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
});
|
||||
|
||||
it("returns rejected error if module already loaded", function(done) {
|
||||
stubs.push(sinon.stub(registry,"getModuleInfo",function(){return{}}));
|
||||
stubs.push(sinon.stub(registry,"getModuleInfo").callsFake(function(){return{}}));
|
||||
loader.init({nodes:nodes,log:{info:function(){},_:function(){}},settings:{available:function(){return true;}}});
|
||||
|
||||
loader.addModule("test-module").catch(function(err) {
|
||||
@ -490,8 +490,8 @@ describe("red/nodes/registry/loader",function() {
|
||||
});
|
||||
});
|
||||
it("returns rejected error if module not found", function(done) {
|
||||
stubs.push(sinon.stub(registry,"getModuleInfo",function(){return null}));
|
||||
stubs.push(sinon.stub(localfilesystem,"getModuleFiles",function() {
|
||||
stubs.push(sinon.stub(registry,"getModuleInfo").callsFake(function(){return null}));
|
||||
stubs.push(sinon.stub(localfilesystem,"getModuleFiles").callsFake(function() {
|
||||
throw new Error("failure");
|
||||
}));
|
||||
loader.init({nodes:nodes,log:{info:function(){},_:function(){}},settings:{available:function(){return true;}}});
|
||||
@ -504,9 +504,9 @@ describe("red/nodes/registry/loader",function() {
|
||||
|
||||
it("loads module by name", function(done) {
|
||||
// This module isn't already loaded
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo", function(){ return null; }));
|
||||
stubs.push(sinon.stub(registry,"getModuleInfo",function(){ return null; }));
|
||||
stubs.push(sinon.stub(localfilesystem,"getModuleFiles", function(){
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo").callsFake(function(){ return null; }));
|
||||
stubs.push(sinon.stub(registry,"getModuleInfo").callsFake(function(){ return null; }));
|
||||
stubs.push(sinon.stub(localfilesystem,"getModuleFiles").callsFake(function(){
|
||||
var result = {};
|
||||
result["TestNodeModule"] = {
|
||||
"name": "TestNodeModule",
|
||||
@ -523,8 +523,8 @@ describe("red/nodes/registry/loader",function() {
|
||||
return result;
|
||||
}));
|
||||
|
||||
stubs.push(sinon.stub(registry,"saveNodeList", function(){ return "a node list" }));
|
||||
stubs.push(sinon.stub(registry,"addModule", function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"saveNodeList").callsFake(function(){ return "a node list" }));
|
||||
stubs.push(sinon.stub(registry,"addModule").callsFake(function(){ return }));
|
||||
stubs.push(sinon.stub(nodes,"registerType"));
|
||||
loader.init({nodes:nodes,log:{info:function(){},_:function(){}},settings:{available:function(){return true;}}});
|
||||
loader.addModule("TestNodeModule").then(function(result) {
|
||||
@ -560,9 +560,9 @@ describe("red/nodes/registry/loader",function() {
|
||||
|
||||
it("skips module that fails version check", function(done) {
|
||||
// This module isn't already loaded
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo", function(){ return null; }));
|
||||
stubs.push(sinon.stub(registry,"getModuleInfo",function(){ return null; }));
|
||||
stubs.push(sinon.stub(localfilesystem,"getModuleFiles", function(){
|
||||
stubs.push(sinon.stub(registry,"getNodeInfo").callsFake(function(){ return null; }));
|
||||
stubs.push(sinon.stub(registry,"getModuleInfo").callsFake(function(){ return null; }));
|
||||
stubs.push(sinon.stub(localfilesystem,"getModuleFiles").callsFake(function(){
|
||||
var result = {};
|
||||
result["TestNodeModule"] = {
|
||||
"name": "TestNodeModule",
|
||||
@ -580,8 +580,8 @@ describe("red/nodes/registry/loader",function() {
|
||||
return result;
|
||||
}));
|
||||
|
||||
stubs.push(sinon.stub(registry,"saveNodeList", function(){ return "a node list" }));
|
||||
stubs.push(sinon.stub(registry,"addModule", function(){ return }));
|
||||
stubs.push(sinon.stub(registry,"saveNodeList").callsFake(function(){ return "a node list" }));
|
||||
stubs.push(sinon.stub(registry,"addModule").callsFake(function(){ return }));
|
||||
stubs.push(sinon.stub(nodes,"registerType"));
|
||||
loader.init({log:{"_":function(){},warn:function(){}},nodes:nodes,version: function() { return "0.12.0"}, settings:{available:function(){return true;}}});
|
||||
loader.addModule("TestNodeModule").then(function(result) {
|
||||
@ -643,7 +643,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
},"en").should.eql("foo");
|
||||
});
|
||||
it("loads help, caching result", function() {
|
||||
stubs.push(sinon.stub(fs,"readFileSync", function(path) {
|
||||
stubs.push(sinon.stub(fs,"readFileSync").callsFake(function(path) {
|
||||
return 'bar';
|
||||
}))
|
||||
var node = {
|
||||
@ -660,7 +660,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
fs.readFileSync.calledOnce.should.be.true();
|
||||
});
|
||||
it("loads help, defaulting to en-US content", function() {
|
||||
stubs.push(sinon.stub(fs,"readFileSync", function(path) {
|
||||
stubs.push(sinon.stub(fs,"readFileSync").callsFake(function(path) {
|
||||
throw new Error("not found");
|
||||
}))
|
||||
var node = {
|
||||
@ -677,7 +677,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
fs.readFileSync.calledOnce.should.be.true();
|
||||
});
|
||||
it("loads help, defaulting to en-US content for extra nodes", function() {
|
||||
stubs.push(sinon.stub(fs,"readFileSync", function(path) {
|
||||
stubs.push(sinon.stub(fs,"readFileSync").callsFake(function(path) {
|
||||
if (path.indexOf("en-US") >= 0) {
|
||||
return 'bar';
|
||||
}
|
||||
@ -698,7 +698,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
fs.readFileSync.calledTwice.should.be.true();
|
||||
});
|
||||
it("fails to load en-US help content", function() {
|
||||
stubs.push(sinon.stub(fs,"readFileSync", function(path) {
|
||||
stubs.push(sinon.stub(fs,"readFileSync").callsFake(function(path) {
|
||||
throw new Error("not found");
|
||||
}));
|
||||
var node = {
|
||||
|
@ -30,7 +30,7 @@ var i18n = NR_TEST_UTILS.require("@node-red/util").i18n;
|
||||
|
||||
describe("red/nodes/registry/localfilesystem",function() {
|
||||
beforeEach(function() {
|
||||
stubs.push(sinon.stub(i18n,"registerMessageCatalog", function() { return Promise.resolve(); }));
|
||||
stubs.push(sinon.stub(i18n,"registerMessageCatalog").callsFake(function() { return Promise.resolve(); }));
|
||||
})
|
||||
|
||||
var stubs = [];
|
||||
@ -131,7 +131,7 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
});
|
||||
it("Finds nodes module path",function(done) {
|
||||
var _join = path.join;
|
||||
stubs.push(sinon.stub(path,"join",function() {
|
||||
stubs.push(sinon.stub(path,"join").callsFake(function() {
|
||||
if (arguments[0] == resourcesDir) {
|
||||
// This stops the module tree scan from going any higher
|
||||
// up the tree than resourcesDir.
|
||||
@ -206,7 +206,7 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
describe("#getModuleFiles",function() {
|
||||
it("gets a nodes module files",function(done) {
|
||||
var _join = path.join;
|
||||
stubs.push(sinon.stub(path,"join",function() {
|
||||
stubs.push(sinon.stub(path,"join").callsFake(function() {
|
||||
if (arguments[0] == resourcesDir) {
|
||||
// This stops the module tree scan from going any higher
|
||||
// up the tree than resourcesDir.
|
||||
@ -232,7 +232,7 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
});
|
||||
it("throws an error if a node isn't found",function(done) {
|
||||
var _join = path.join;
|
||||
stubs.push(sinon.stub(path,"join",function() {
|
||||
stubs.push(sinon.stub(path,"join").callsFake(function() {
|
||||
if (arguments[0] == resourcesDir) {
|
||||
// This stops the module tree scan from going any higher
|
||||
// up the tree than resourcesDir.
|
||||
@ -251,7 +251,7 @@ describe("red/nodes/registry/localfilesystem",function() {
|
||||
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() {
|
||||
stubs.push(sinon.stub(path,"join").callsFake(function() {
|
||||
if (arguments[0] == resourcesDir) {
|
||||
// This stops the module tree scan from going any higher
|
||||
// up the tree than resourcesDir.
|
||||
|
@ -37,8 +37,8 @@ describe("red/nodes/registry/plugins",function() {
|
||||
}
|
||||
}
|
||||
events.on("registry:plugin-added",handleEvent);
|
||||
sinon.stub(registry,"getModule", moduleId => modules[moduleId]);
|
||||
sinon.stub(registry,"getModuleList", () => modules)
|
||||
sinon.stub(registry,"getModule").callsFake(moduleId => modules[moduleId]);
|
||||
sinon.stub(registry,"getModuleList").callsFake(() => modules)
|
||||
});
|
||||
afterEach(function() {
|
||||
events.removeListener("registry:plugin-added",handleEvent);
|
||||
|
@ -31,8 +31,8 @@ describe("runtime-api/comms", function() {
|
||||
}
|
||||
var eventHandlers = {};
|
||||
before(function(done) {
|
||||
sinon.stub(events,"removeListener", function() {})
|
||||
sinon.stub(events,"on", function(evt,handler) { eventHandlers[evt] = handler })
|
||||
sinon.stub(events,"removeListener").callsFake(function() {})
|
||||
sinon.stub(events,"on").callsFake(function(evt,handler) { eventHandlers[evt] = handler })
|
||||
comms.init({
|
||||
log: {
|
||||
trace: function(){}
|
||||
@ -97,8 +97,8 @@ describe("runtime-api/comms", function() {
|
||||
}
|
||||
}
|
||||
before(function() {
|
||||
sinon.stub(events,"removeListener", function() {})
|
||||
sinon.stub(events,"on", function(evt,handler) { eventHandlers[evt] = handler })
|
||||
sinon.stub(events,"removeListener").callsFake(function() {})
|
||||
sinon.stub(events,"on").callsFake(function(evt,handler) { eventHandlers[evt] = handler })
|
||||
comms.init({
|
||||
log: {
|
||||
trace: function(){}
|
||||
@ -177,8 +177,8 @@ describe("runtime-api/comms", function() {
|
||||
}
|
||||
var eventHandlers = {};
|
||||
before(function() {
|
||||
sinon.stub(events,"removeListener", function() {})
|
||||
sinon.stub(events,"on", function(evt,handler) { eventHandlers[evt] = handler })
|
||||
sinon.stub(events,"removeListener").callsFake(function() {})
|
||||
sinon.stub(events,"on").callsFake(function(evt,handler) { eventHandlers[evt] = handler })
|
||||
comms.init({
|
||||
log: {
|
||||
trace: function(){}
|
||||
|
@ -24,7 +24,7 @@ var index = NR_TEST_UTILS.require("@node-red/runtime/lib/api/index");
|
||||
describe("runtime-api/index", function() {
|
||||
before(function() {
|
||||
["comms","flows","nodes","settings","library","projects"].forEach(n => {
|
||||
sinon.stub(NR_TEST_UTILS.require(`@node-red/runtime/lib/api/${n}`),"init",()=>{});
|
||||
sinon.stub(NR_TEST_UTILS.require(`@node-red/runtime/lib/api/${n}`),"init").callsFake(()=>{});
|
||||
})
|
||||
});
|
||||
after(function() {
|
||||
|
@ -217,7 +217,7 @@ describe("api/admin/nodes", function() {
|
||||
app.put(/\/nodes\/((@[^\/]+\/)?[^\/]+)\/([^\/]+)$/,nodes.putSet);
|
||||
app.get("/getIcons",nodes.getIcons);
|
||||
app.delete("/nodes/:id",nodes.delete);
|
||||
sinon.stub(apiUtil,"determineLangFromHeaders", function() {
|
||||
sinon.stub(apiUtil,"determineLangFromHeaders").callsFake(function() {
|
||||
return "en-US";
|
||||
});
|
||||
});
|
||||
|
@ -173,7 +173,7 @@ describe('Flow', function() {
|
||||
util.inherits(TestDoneNode,Node);
|
||||
|
||||
before(function() {
|
||||
getType = sinon.stub(typeRegistry,"get",function(type) {
|
||||
getType = sinon.stub(typeRegistry,"get").callsFake(function(type) {
|
||||
if (type=="test") {
|
||||
return TestNode;
|
||||
} else if (type=="testError"){
|
||||
|
@ -202,7 +202,7 @@ describe('Subflow', function() {
|
||||
util.inherits(TestEnvNode,Node);
|
||||
|
||||
before(function() {
|
||||
getType = sinon.stub(typeRegistry,"get",function(type) {
|
||||
getType = sinon.stub(typeRegistry,"get").callsFake(function(type) {
|
||||
if (type=="test") {
|
||||
return TestNode;
|
||||
} else if (type=="testError"){
|
||||
|
@ -51,10 +51,10 @@ describe('flows/index', function() {
|
||||
|
||||
|
||||
before(function() {
|
||||
getType = sinon.stub(typeRegistry,"get",function(type) {
|
||||
getType = sinon.stub(typeRegistry,"get").callsFake(function(type) {
|
||||
return type.indexOf('missing') === -1;
|
||||
});
|
||||
checkFlowDependencies = sinon.stub(typeRegistry, "checkFlowDependencies", async function(flow) {
|
||||
checkFlowDependencies = sinon.stub(typeRegistry, "checkFlowDependencies").callsFake(async function(flow) {
|
||||
if (flow[0].id === "node-with-missing-modules") {
|
||||
throw new Error("Missing module");
|
||||
}
|
||||
@ -69,20 +69,20 @@ describe('flows/index', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
eventsOn = sinon.spy(events,"on");
|
||||
credentialsClean = sinon.stub(credentials,"clean",function(conf) {
|
||||
credentialsClean = sinon.stub(credentials,"clean").callsFake(function(conf) {
|
||||
conf.forEach(function(n) {
|
||||
delete n.credentials;
|
||||
});
|
||||
return Promise.resolve();
|
||||
});
|
||||
credentialsLoad = sinon.stub(credentials,"load",function(creds) {
|
||||
credentialsLoad = sinon.stub(credentials,"load").callsFake(function(creds) {
|
||||
if (creds && creds.hasOwnProperty("$") && creds['$'] === "fail") {
|
||||
return Promise.reject("creds error");
|
||||
}
|
||||
return Promise.resolve();
|
||||
});
|
||||
credentialsAdd = sinon.stub(credentials,"add", async function(id, conf){})
|
||||
flowCreate = sinon.stub(Flow,"create",function(parent, global, flow) {
|
||||
credentialsAdd = sinon.stub(credentials,"add").callsFake(async function(id, conf){})
|
||||
flowCreate = sinon.stub(Flow,"create").callsFake(function(parent, global, flow) {
|
||||
var id;
|
||||
if (typeof flow === 'undefined') {
|
||||
flow = global;
|
||||
@ -551,7 +551,7 @@ describe('flows/index', function() {
|
||||
describe('#checkTypeInUse', function() {
|
||||
|
||||
before(function() {
|
||||
sinon.stub(typeRegistry,"getNodeInfo",function(id) {
|
||||
sinon.stub(typeRegistry,"getNodeInfo").callsFake(function(id) {
|
||||
if (id === 'unused-module') {
|
||||
return {types:['one','two','three']}
|
||||
} else {
|
||||
|
@ -26,7 +26,7 @@ describe('flows/util', function() {
|
||||
var getType;
|
||||
|
||||
before(function() {
|
||||
getType = sinon.stub(typeRegistry,"get",function(type) {
|
||||
getType = sinon.stub(typeRegistry,"get").callsFake(function(type) {
|
||||
return type!=='missing';
|
||||
});
|
||||
});
|
||||
|
@ -44,13 +44,13 @@ describe("runtime", function() {
|
||||
delete process.env.NODE_RED_HOME;
|
||||
});
|
||||
function mockUtil(metrics) {
|
||||
sinon.stub(log,"log",function(){})
|
||||
sinon.stub(log,"warn",function(){})
|
||||
sinon.stub(log,"info",function(){})
|
||||
sinon.stub(log,"trace",function(){})
|
||||
sinon.stub(log,"metric",function(){ return !!metrics })
|
||||
sinon.stub(log,"_",function(){ return "abc"})
|
||||
sinon.stub(i18n,"registerMessageCatalog",function(){ return Promise.resolve()})
|
||||
sinon.stub(log,"log").callsFake(function(){})
|
||||
sinon.stub(log,"warn").callsFake(function(){})
|
||||
sinon.stub(log,"info").callsFake(function(){})
|
||||
sinon.stub(log,"trace").callsFake(function(){})
|
||||
sinon.stub(log,"metric").callsFake(function(){ return !!metrics })
|
||||
sinon.stub(log,"_").callsFake(function(){ return "abc"})
|
||||
sinon.stub(i18n,"registerMessageCatalog").callsFake(function(){ return Promise.resolve()})
|
||||
}
|
||||
function unmockUtil() {
|
||||
log.log.restore && log.log.restore();
|
||||
@ -63,9 +63,9 @@ describe("runtime", function() {
|
||||
}
|
||||
describe("init", function() {
|
||||
beforeEach(function() {
|
||||
sinon.stub(log,"init",function() {});
|
||||
sinon.stub(settings,"init",function() {});
|
||||
sinon.stub(redNodes,"init",function() {})
|
||||
sinon.stub(log,"init").callsFake(function() {});
|
||||
sinon.stub(settings,"init").callsFake(function() {});
|
||||
sinon.stub(redNodes,"init").callsFake(function() {})
|
||||
mockUtil();
|
||||
});
|
||||
afterEach(function() {
|
||||
@ -103,13 +103,13 @@ describe("runtime", function() {
|
||||
var redNodesLoadContextsPlugin;
|
||||
|
||||
beforeEach(function() {
|
||||
storageInit = sinon.stub(storage,"init",function(settings) {return Promise.resolve();});
|
||||
redNodesInit = sinon.stub(redNodes,"init", function() {});
|
||||
redNodesLoad = sinon.stub(redNodes,"load", function() {return Promise.resolve()});
|
||||
redNodesCleanModuleList = sinon.stub(redNodes,"cleanModuleList",function(){});
|
||||
redNodesLoadFlows = sinon.stub(redNodes,"loadFlows",function() {return Promise.resolve()});
|
||||
redNodesStartFlows = sinon.stub(redNodes,"startFlows",function() {});
|
||||
redNodesLoadContextsPlugin = sinon.stub(redNodes,"loadContextsPlugin",function() {return Promise.resolve()});
|
||||
storageInit = sinon.stub(storage,"init").callsFake(function(settings) {return Promise.resolve();});
|
||||
redNodesInit = sinon.stub(redNodes,"init").callsFake(function() {});
|
||||
redNodesLoad = sinon.stub(redNodes,"load").callsFake(function() {return Promise.resolve()});
|
||||
redNodesCleanModuleList = sinon.stub(redNodes,"cleanModuleList").callsFake(function(){});
|
||||
redNodesLoadFlows = sinon.stub(redNodes,"loadFlows").callsFake(function() {return Promise.resolve()});
|
||||
redNodesStartFlows = sinon.stub(redNodes,"startFlows").callsFake(function() {});
|
||||
redNodesLoadContextsPlugin = sinon.stub(redNodes,"loadContextsPlugin").callsFake(function() {return Promise.resolve()});
|
||||
mockUtil();
|
||||
});
|
||||
afterEach(function() {
|
||||
@ -124,7 +124,7 @@ describe("runtime", function() {
|
||||
unmockUtil();
|
||||
});
|
||||
it("reports errored/missing modules",function(done) {
|
||||
redNodesGetNodeList = sinon.stub(redNodes,"getNodeList", function(cb) {
|
||||
redNodesGetNodeList = sinon.stub(redNodes,"getNodeList").callsFake(function(cb) {
|
||||
return [
|
||||
{ err:"errored",name:"errName" }, // error
|
||||
{ module:"module",enabled:true,loaded:false,types:["typeA","typeB"]} // missing
|
||||
@ -151,7 +151,7 @@ describe("runtime", function() {
|
||||
}).catch(err=>{done(err)});
|
||||
});
|
||||
it("initiates load of missing modules",function(done) {
|
||||
redNodesGetNodeList = sinon.stub(redNodes,"getNodeList", function(cb) {
|
||||
redNodesGetNodeList = sinon.stub(redNodes,"getNodeList").callsFake(function(cb) {
|
||||
return [
|
||||
{ err:"errored",name:"errName" }, // error
|
||||
{ err:"errored",name:"errName" }, // error
|
||||
@ -159,7 +159,7 @@ describe("runtime", function() {
|
||||
{ module:"node-red",enabled:true,loaded:false,types:["typeC","typeD"]} // missing
|
||||
].filter(cb);
|
||||
});
|
||||
var serverInstallModule = sinon.stub(redNodes,"installModule",function(name) { return Promise.resolve({nodes:[]});});
|
||||
var serverInstallModule = sinon.stub(redNodes,"installModule").callsFake(function(name) { return Promise.resolve({nodes:[]});});
|
||||
runtime.init({testSettings: true, autoInstallModules:true, httpAdminRoot:"/", load:function() { return Promise.resolve();}});
|
||||
sinon.stub(console,"log");
|
||||
runtime.start().then(function() {
|
||||
@ -181,7 +181,7 @@ describe("runtime", function() {
|
||||
}).catch(err=>{done(err)});
|
||||
});
|
||||
it("reports errored modules when verbose is enabled",function(done) {
|
||||
redNodesGetNodeList = sinon.stub(redNodes,"getNodeList", function(cb) {
|
||||
redNodesGetNodeList = sinon.stub(redNodes,"getNodeList").callsFake(function(cb) {
|
||||
return [
|
||||
{ err:"errored",name:"errName" } // error
|
||||
].filter(cb);
|
||||
@ -201,8 +201,8 @@ describe("runtime", function() {
|
||||
});
|
||||
|
||||
it("reports runtime metrics",function(done) {
|
||||
var stopFlows = sinon.stub(redNodes,"stopFlows",function() { return Promise.resolve();} );
|
||||
redNodesGetNodeList = sinon.stub(redNodes,"getNodeList", function() {return []});
|
||||
var stopFlows = sinon.stub(redNodes,"stopFlows").callsFake(function() { return Promise.resolve();} );
|
||||
redNodesGetNodeList = sinon.stub(redNodes,"getNodeList").callsFake(function() {return []});
|
||||
unmockUtil();
|
||||
mockUtil(true);
|
||||
runtime.init(
|
||||
@ -233,8 +233,8 @@ describe("runtime", function() {
|
||||
});
|
||||
|
||||
it("stops components", function(done) {
|
||||
var stopFlows = sinon.stub(redNodes,"stopFlows",function() { return Promise.resolve();} );
|
||||
var closeContextsPlugin = sinon.stub(redNodes,"closeContextsPlugin",function() { return Promise.resolve();} );
|
||||
var stopFlows = sinon.stub(redNodes,"stopFlows").callsFake(function() { return Promise.resolve();} );
|
||||
var closeContextsPlugin = sinon.stub(redNodes,"closeContextsPlugin").callsFake(function() { return Promise.resolve();} );
|
||||
runtime.stop().then(function(){
|
||||
stopFlows.called.should.be.true();
|
||||
closeContextsPlugin.called.should.be.true();
|
||||
|
@ -65,7 +65,7 @@ describe("runtime/library/examples", function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
sinon.stub(fs,"readFile", function(path,opts,callback) {
|
||||
sinon.stub(fs,"readFile").callsFake(function(path,opts,callback) {
|
||||
if (path === "/tmp/test-module/abc") {
|
||||
callback(null,"Example flow result");
|
||||
} else if (path === "/tmp/@scope/test-module/abc") {
|
||||
|
@ -37,14 +37,14 @@ var mockLog = {
|
||||
|
||||
describe("runtime/library", function() {
|
||||
before(function() {
|
||||
sinon.stub(localLibrary,"getEntry",function(type,path) {
|
||||
sinon.stub(localLibrary,"getEntry").callsFake(function(type,path) {
|
||||
return Promise.resolve({
|
||||
library: "local",
|
||||
type:type,
|
||||
path:path
|
||||
})
|
||||
});
|
||||
sinon.stub(localLibrary,"saveEntry",function(type, path, meta, body) {
|
||||
sinon.stub(localLibrary,"saveEntry").callsFake(function(type, path, meta, body) {
|
||||
return Promise.resolve({
|
||||
library: "local",
|
||||
type:type,
|
||||
@ -53,7 +53,7 @@ describe("runtime/library", function() {
|
||||
body:body
|
||||
})
|
||||
});
|
||||
sinon.stub(examplesLibrary,"getEntry",function(type,path) {
|
||||
sinon.stub(examplesLibrary,"getEntry").callsFake(function(type,path) {
|
||||
return Promise.resolve({
|
||||
library: "_examples_",
|
||||
type:type,
|
||||
|
@ -151,7 +151,7 @@ describe('Node', function() {
|
||||
|
||||
it('handles thrown errors', function(done) {
|
||||
var n = new RedNode({id:'123',type:'abc'});
|
||||
sinon.stub(n,"error",function(err,msg) {});
|
||||
sinon.stub(n,"error").callsFake(function(err,msg) {});
|
||||
var message = {payload:"hello world"};
|
||||
n.on('input',function(msg) {
|
||||
throw new Error("test error");
|
||||
@ -271,7 +271,7 @@ describe('Node', function() {
|
||||
});
|
||||
it('logs error if callback provides error', function(done) {
|
||||
var n = new RedNode({id:'123',type:'abc'});
|
||||
sinon.stub(n,"error",function(err,msg) {});
|
||||
sinon.stub(n,"error").callsFake(function(err,msg) {});
|
||||
|
||||
var message = {payload:"hello world"};
|
||||
n.on('input',function(msg, nodeSend, nodeDone) {
|
||||
@ -723,7 +723,7 @@ describe('Node', function() {
|
||||
it('produces a metric message', function(done) {
|
||||
var n = new RedNode({id:'123',type:'abc'});
|
||||
var loginfo = {};
|
||||
sinon.stub(Log, 'log', function(msg) {
|
||||
sinon.stub(Log, 'log').callsFake(function(msg) {
|
||||
loginfo = msg;
|
||||
});
|
||||
var msg = {payload:"foo", _msgid:"987654321"};
|
||||
@ -739,7 +739,7 @@ describe('Node', function() {
|
||||
it('returns metric value if eventname undefined', function(done) {
|
||||
var n = new RedNode({id:'123',type:'abc'});
|
||||
var loginfo = {};
|
||||
sinon.stub(Log, 'log', function(msg) {
|
||||
sinon.stub(Log, 'log').callsFake(function(msg) {
|
||||
loginfo = msg;
|
||||
});
|
||||
var msg = {payload:"foo", _msgid:"987654321"};
|
||||
@ -751,7 +751,7 @@ describe('Node', function() {
|
||||
it('returns not defined if eventname defined', function(done) {
|
||||
var n = new RedNode({id:'123',type:'abc'});
|
||||
var loginfo = {};
|
||||
sinon.stub(Log, 'log', function(msg) {
|
||||
sinon.stub(Log, 'log').callsFake(function(msg) {
|
||||
loginfo = msg;
|
||||
});
|
||||
var msg = {payload:"foo", _msgid:"987654321"};
|
||||
|
@ -320,7 +320,7 @@ describe('context', function() {
|
||||
|
||||
describe('external context storage',function() {
|
||||
var resourcesDir = path.resolve(path.join(__dirname,"..","resources","context"));
|
||||
var sandbox = sinon.sandbox.create();
|
||||
var sandbox = sinon.createSandbox();
|
||||
var stubGet = sandbox.stub();
|
||||
var stubSet = sandbox.stub();
|
||||
var stubKeys = sandbox.stub();
|
||||
|
@ -177,15 +177,15 @@ describe("red/nodes/index", function() {
|
||||
|
||||
var userDir = path.join(__dirname,".testUserHome");
|
||||
before(function(done) {
|
||||
sinon.stub(log,"log",function(){});
|
||||
sinon.stub(log,"log").callsFake(function(){});
|
||||
fs.remove(userDir,function(err) {
|
||||
fs.mkdir(userDir,function() {
|
||||
sinon.stub(index, 'load', function() {
|
||||
sinon.stub(index, 'load').callsFake(function() {
|
||||
return new Promise(function(resolve,reject){
|
||||
resolve([]);
|
||||
});
|
||||
});
|
||||
sinon.stub(localfilesystem, 'getCredentials', function() {
|
||||
sinon.stub(localfilesystem, 'getCredentials').callsFake(function() {
|
||||
return new Promise(function(resolve,reject) {
|
||||
resolve({"tab1":{"b":1,"c":2}});
|
||||
});
|
||||
@ -271,7 +271,7 @@ describe("red/nodes/index", function() {
|
||||
var randomNodeInfo = {id:"5678",types:["random"]};
|
||||
|
||||
beforeEach(function() {
|
||||
sinon.stub(registry,"getNodeInfo",function(id) {
|
||||
sinon.stub(registry,"getNodeInfo").callsFake(function(id) {
|
||||
if (id == "test") {
|
||||
return {id:"1234",types:["test"]};
|
||||
} else if (id == "doesnotexist") {
|
||||
@ -280,7 +280,7 @@ describe("red/nodes/index", function() {
|
||||
return randomNodeInfo;
|
||||
}
|
||||
});
|
||||
sinon.stub(registry,"disableNode",function(id) {
|
||||
sinon.stub(registry,"disableNode").callsFake(function(id) {
|
||||
return Promise.resolve(randomNodeInfo);
|
||||
});
|
||||
});
|
||||
@ -343,7 +343,7 @@ describe("red/nodes/index", function() {
|
||||
};
|
||||
|
||||
before(function() {
|
||||
sinon.stub(registry,"getNodeInfo",function(id) {
|
||||
sinon.stub(registry,"getNodeInfo").callsFake(function(id) {
|
||||
if (id == "node-red/foo") {
|
||||
return {id:"1234",types:["test"]};
|
||||
} else if (id == "doesnotexist") {
|
||||
@ -352,7 +352,7 @@ describe("red/nodes/index", function() {
|
||||
return randomNodeInfo;
|
||||
}
|
||||
});
|
||||
sinon.stub(registry,"getModuleInfo",function(module) {
|
||||
sinon.stub(registry,"getModuleInfo").callsFake(function(module) {
|
||||
if (module == "node-red") {
|
||||
return {nodes:[{name:"foo"}]};
|
||||
} else if (module == "doesnotexist") {
|
||||
@ -361,7 +361,7 @@ describe("red/nodes/index", function() {
|
||||
return randomModuleInfo;
|
||||
}
|
||||
});
|
||||
sinon.stub(registry,"removeModule",function(id) {
|
||||
sinon.stub(registry,"removeModule").callsFake(function(id) {
|
||||
return randomModuleInfo;
|
||||
});
|
||||
});
|
||||
|
@ -313,7 +313,7 @@ describe('storage/localfilesystem', function() {
|
||||
var flowFile = 'test.json';
|
||||
var flowFilePath = path.join(userDir,flowFile);
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath,getUserSettings: () => {{}}}, mockRuntime).then(function() {
|
||||
sinon.stub(fs,"fsync", function(fd, cb) {
|
||||
sinon.stub(fs,"fsync").callsFake(function(fd, cb) {
|
||||
cb(new Error());
|
||||
});
|
||||
sinon.spy(log,"warn");
|
||||
|
@ -34,7 +34,7 @@ describe("localfilesystem/projects/ssh/keygen", function() {
|
||||
var command;
|
||||
var args;
|
||||
var opts;
|
||||
sinon.stub(child_process,"spawn", function(_command,_args,_opts) {
|
||||
sinon.stub(child_process,"spawn").callsFake(function(_command,_args,_opts) {
|
||||
_command = command;
|
||||
_args = args;
|
||||
_opts = opts;
|
||||
|
@ -41,7 +41,7 @@ describe("runtime/exec", function() {
|
||||
mockProcess = new EventEmitter();
|
||||
mockProcess.stdout = new EventEmitter();
|
||||
mockProcess.stderr = new EventEmitter();
|
||||
sinon.stub(child_process,'spawn',function(command,args,options) {
|
||||
sinon.stub(child_process,'spawn').callsFake(function(command,args,options) {
|
||||
mockProcess._args = {command,args,options};
|
||||
return mockProcess;
|
||||
});
|
||||
|
@ -24,7 +24,7 @@ var log = NR_TEST_UTILS.require("@node-red/util").log;
|
||||
|
||||
describe("@node-red/util/log", function() {
|
||||
beforeEach(function () {
|
||||
var spy = sinon.stub(util, 'log', function(arg){});
|
||||
var spy = sinon.stub(util, 'log').callsFake(function(arg){});
|
||||
var settings = {logging: { console: { level: 'metric', metrics: true } } };
|
||||
log.init(settings);
|
||||
});
|
||||
|
@ -33,9 +33,9 @@ describe("red/red", function() {
|
||||
|
||||
// describe("check build", function() {
|
||||
// beforeEach(function() {
|
||||
// sinon.stub(runtime,"init",function() {});
|
||||
// sinon.stub(api,"init",function() {});
|
||||
// // sinon.stub(RED,"version",function() { return "version";});
|
||||
// sinon.stub(runtime,"init").callsFake(function() {});
|
||||
// sinon.stub(api,"init").callsFake(function() {});
|
||||
// // sinon.stub(RED,"version").callsFake(function() { return "version";});
|
||||
// });
|
||||
// afterEach(function() {
|
||||
// runtime.init.restore();
|
||||
@ -44,7 +44,7 @@ describe("red/red", function() {
|
||||
// // RED.version.restore();
|
||||
// });
|
||||
// it.skip('warns if build has not been run',function() {
|
||||
// sinon.stub(fs,"statSync",function() { throw new Error();});
|
||||
// sinon.stub(fs,"statSync").callsFake(function() { throw new Error();});
|
||||
//
|
||||
// /*jshint immed: false */
|
||||
// (function() {
|
||||
@ -52,7 +52,7 @@ describe("red/red", function() {
|
||||
// }).should.throw("Node-RED not built");
|
||||
// });
|
||||
// it('passed if build has been run',function() {
|
||||
// sinon.stub(fs,"statSync",function() { });
|
||||
// sinon.stub(fs,"statSync").callsFake(function() { });
|
||||
// RED.init({},{});
|
||||
// });
|
||||
// });
|
||||
|
Loading…
Reference in New Issue
Block a user