mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Update to latest sinon
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user