mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Fixup all the tests
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
var should = require("should");
|
||||
var when = require("when");
|
||||
var sinon = require("sinon");
|
||||
var path = require("path");
|
||||
|
||||
@@ -45,6 +44,7 @@ describe("runtime", function() {
|
||||
log: sinon.stub(),
|
||||
warn: sinon.stub(),
|
||||
info: sinon.stub(),
|
||||
trace: sinon.stub(),
|
||||
metric: sinon.stub().returns(!!metrics),
|
||||
_: function() { return "abc"}
|
||||
},
|
||||
@@ -90,11 +90,11 @@ describe("runtime", function() {
|
||||
var redNodesLoadFlows;
|
||||
var redNodesStartFlows;
|
||||
beforeEach(function() {
|
||||
storageInit = sinon.stub(storage,"init",function(settings) {return when.resolve();});
|
||||
storageInit = sinon.stub(storage,"init",function(settings) {return Promise.resolve();});
|
||||
redNodesInit = sinon.stub(redNodes,"init", function() {});
|
||||
redNodesLoad = sinon.stub(redNodes,"load", function() {return when.resolve()});
|
||||
redNodesLoad = sinon.stub(redNodes,"load", function() {return Promise.resolve()});
|
||||
redNodesCleanModuleList = sinon.stub(redNodes,"cleanModuleList",function(){});
|
||||
redNodesLoadFlows = sinon.stub(redNodes,"loadFlows",function() {return when.resolve()});
|
||||
redNodesLoadFlows = sinon.stub(redNodes,"loadFlows",function() {return Promise.resolve()});
|
||||
redNodesStartFlows = sinon.stub(redNodes,"startFlows",function() {});
|
||||
});
|
||||
afterEach(function() {
|
||||
@@ -114,7 +114,7 @@ describe("runtime", function() {
|
||||
].filter(cb);
|
||||
});
|
||||
var util = mockUtil();
|
||||
runtime.init({testSettings: true, httpAdminRoot:"/", load:function() { return when.resolve();}},util);
|
||||
runtime.init({testSettings: true, httpAdminRoot:"/", load:function() { return Promise.resolve();}},util);
|
||||
// sinon.stub(console,"log");
|
||||
runtime.start().then(function() {
|
||||
// console.log.restore();
|
||||
@@ -143,9 +143,9 @@ 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 when.resolve({nodes:[]});});
|
||||
var serverInstallModule = sinon.stub(redNodes,"installModule",function(name) { return Promise.resolve({nodes:[]});});
|
||||
var util = mockUtil();
|
||||
runtime.init({testSettings: true, autoInstallModules:true, httpAdminRoot:"/", load:function() { return when.resolve();}},util);
|
||||
runtime.init({testSettings: true, autoInstallModules:true, httpAdminRoot:"/", load:function() { return Promise.resolve();}},util);
|
||||
sinon.stub(console,"log");
|
||||
runtime.start().then(function() {
|
||||
console.log.restore();
|
||||
@@ -172,7 +172,7 @@ describe("runtime", function() {
|
||||
].filter(cb);
|
||||
});
|
||||
var util = mockUtil();
|
||||
runtime.init({testSettings: true, verbose:true, httpAdminRoot:"/", load:function() { return when.resolve();}},util);
|
||||
runtime.init({testSettings: true, verbose:true, httpAdminRoot:"/", load:function() { return Promise.resolve();}},util);
|
||||
sinon.stub(console,"log");
|
||||
runtime.start().then(function() {
|
||||
console.log.restore();
|
||||
@@ -190,7 +190,7 @@ describe("runtime", function() {
|
||||
var stopFlows = sinon.stub(redNodes,"stopFlows",function() {} );
|
||||
redNodesGetNodeList = sinon.stub(redNodes,"getNodeList", function() {return []});
|
||||
var util = mockUtil(true);
|
||||
runtime.init({testSettings: true, runtimeMetricInterval:200, httpAdminRoot:"/", load:function() { return when.resolve();}},util);
|
||||
runtime.init({testSettings: true, runtimeMetricInterval:200, httpAdminRoot:"/", load:function() { return Promise.resolve();}},util);
|
||||
sinon.stub(console,"log");
|
||||
runtime.start().then(function() {
|
||||
console.log.restore();
|
||||
|
@@ -14,6 +14,167 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var should = require("should");
|
||||
var sinon = require("sinon");
|
||||
var fs = require("fs");
|
||||
|
||||
var library = require("../../../../red/runtime/library/index")
|
||||
|
||||
var mockLog = {
|
||||
log: sinon.stub(),
|
||||
debug: sinon.stub(),
|
||||
trace: sinon.stub(),
|
||||
warn: sinon.stub(),
|
||||
info: sinon.stub(),
|
||||
metric: sinon.stub(),
|
||||
audit: sinon.stub(),
|
||||
_: function() { return "abc"}
|
||||
}
|
||||
|
||||
|
||||
describe("runtime/library", function() {
|
||||
it.skip('more tests needed', function(){})
|
||||
describe("register", function() {
|
||||
// it("throws error for duplicate type", function() {
|
||||
// library.init({});
|
||||
// library.register("unknown","/abc");
|
||||
// should(()=>{library.register("unknown","/abc")} ).throw();
|
||||
// })
|
||||
})
|
||||
describe("getEntry", function() {
|
||||
before(function() {
|
||||
library.init({
|
||||
log: mockLog,
|
||||
storage: {
|
||||
getLibraryEntry: function(type,path) {
|
||||
return Promise.resolve({type,path});
|
||||
},
|
||||
getFlow: function(path) {
|
||||
return Promise.resolve({path});
|
||||
}
|
||||
},
|
||||
nodes: {
|
||||
getNodeExampleFlowPath: function(module,entryPath) {
|
||||
if (module === "unknown") {
|
||||
return null;
|
||||
}
|
||||
return "/tmp/"+module+"/"+entryPath;
|
||||
}
|
||||
}
|
||||
});
|
||||
sinon.stub(fs,"readFile", function(path,opts,callback) {
|
||||
if (path === "/tmp/test-module/abc") {
|
||||
callback(null,"Example flow result");
|
||||
} else if (path === "/tmp/@scope/test-module/abc") {
|
||||
callback(null,"Example scope flow result");
|
||||
} else if (path === "/tmp/test-module/throw") {
|
||||
throw new Error("Instant error")
|
||||
} else {
|
||||
callback(new Error("Unexpected path:"+path))
|
||||
}
|
||||
})
|
||||
});
|
||||
after(function() {
|
||||
fs.readFile.restore();
|
||||
})
|
||||
it('throws error for unregistered type', function() {
|
||||
should(()=>{library.getEntry("unknown","/abc")} ).throw();
|
||||
});
|
||||
|
||||
it('returns a registered non-flow entry', function(done) {
|
||||
library.register("test-module","test-type");
|
||||
library.getEntry("test-type","/abc").then(function(result) {
|
||||
result.should.have.property("type","test-type")
|
||||
result.should.have.property("path","/abc")
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
it ('returns a flow entry', function(done) {
|
||||
library.getEntry("flows","/abc").then(function(result) {
|
||||
result.should.have.property("path","/abc")
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
it ('returns a flow example entry', function(done) {
|
||||
library.getEntry("flows","_examples_/test-module/abc").then(function(result) {
|
||||
result.should.eql("Example flow result");
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
it ('returns a flow example entry from scoped module', function(done) {
|
||||
library.getEntry("flows","_examples_/@scope/test-module/abc").then(function(result) {
|
||||
result.should.eql("Example scope flow result");
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
it ('returns an error for unknown flow example entry', function(done) {
|
||||
library.getEntry("flows","_examples_/unknown/abc").then(function(result) {
|
||||
done(new Error("No error thrown"))
|
||||
}).catch(function(err) {
|
||||
err.should.have.property("code","not_found");
|
||||
done();
|
||||
});
|
||||
});
|
||||
it ('returns an error for file load error - async', function(done) {
|
||||
library.getEntry("flows","_examples_/test-module/unknown").then(function(result) {
|
||||
done(new Error("No error thrown"))
|
||||
}).catch(function(err) {
|
||||
done();
|
||||
});
|
||||
});
|
||||
it ('returns an error for file load error - sync', function(done) {
|
||||
library.getEntry("flows","_examples_/test-module/throw").then(function(result) {
|
||||
done(new Error("No error thrown"))
|
||||
}).catch(function(err) {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("saveEntry", function() {
|
||||
before(function() {
|
||||
library.init({
|
||||
log: mockLog,
|
||||
storage: {
|
||||
saveLibraryEntry: function(type, path, meta, body) {
|
||||
return Promise.resolve({type,path,meta,body})
|
||||
},
|
||||
saveFlow: function(path,body) {
|
||||
return Promise.resolve({path,body});
|
||||
}
|
||||
},
|
||||
nodes: {
|
||||
getNodeExampleFlowPath: function(module,entryPath) {
|
||||
if (module === "unknown") {
|
||||
return null;
|
||||
}
|
||||
return "/tmp/"+module+"/"+entryPath;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
it('throws error for unregistered type', function() {
|
||||
should(()=>{library.saveEntry("unknown","/abc",{id:"meta"},{id:"body"})} ).throw();
|
||||
});
|
||||
it('saves a flow entry', function(done) {
|
||||
library.saveEntry('flows','/abc',{id:"meta"},{id:"body"}).then(function(result) {
|
||||
result.should.have.property("path","/abc");
|
||||
result.should.have.property("body",{id:"body"});
|
||||
done();
|
||||
}).catch(done);
|
||||
})
|
||||
it('saves a non-flow entry', function(done) {
|
||||
library.register("test-module","test-type");
|
||||
library.saveEntry('test-type','/abc',{id:"meta"},{id:"body"}).then(function(result) {
|
||||
result.should.have.property("type","test-type");
|
||||
result.should.have.property("path","/abc");
|
||||
result.should.have.property("meta",{id:"meta"});
|
||||
result.should.have.property("body",{id:"body"});
|
||||
done();
|
||||
}).catch(done);
|
||||
})
|
||||
|
||||
});
|
||||
});
|
||||
|
@@ -110,7 +110,7 @@ describe('Node', function() {
|
||||
p.then(function() {
|
||||
callbacksClosed.should.eql(3);
|
||||
testdone();
|
||||
}).otherwise(function(e) {
|
||||
}).catch(function(e) {
|
||||
testdone(e);
|
||||
});
|
||||
});
|
||||
|
@@ -427,7 +427,7 @@ describe('red/runtime/nodes/credentials', function() {
|
||||
// credentials.dirty().should.be.true();
|
||||
// should.not.exist(credentials.get("node"));
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
err.should.have.property('code','credentials_load_failed');
|
||||
done();
|
||||
});
|
||||
@@ -443,7 +443,7 @@ describe('red/runtime/nodes/credentials', function() {
|
||||
// credentials.dirty().should.be.true();
|
||||
// should.not.exist(credentials.get("node"));
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
err.should.have.property('code','credentials_load_failed');
|
||||
done();
|
||||
});
|
||||
|
@@ -524,7 +524,7 @@ describe('flows/index', function() {
|
||||
]
|
||||
}).then(function() {
|
||||
done(new Error('failed to reject duplicate node id'));
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done();
|
||||
})
|
||||
});
|
||||
@@ -559,7 +559,7 @@ describe('flows/index', function() {
|
||||
createdFlows.should.have.lengthOf(3);
|
||||
createdFlows[2].should.eql(id);
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
})
|
||||
});
|
||||
|
@@ -19,7 +19,6 @@ var fs = require('fs-extra');
|
||||
var path = require('path');
|
||||
var when = require("when");
|
||||
var sinon = require('sinon');
|
||||
console.log(__dirname);
|
||||
var index = require("../../../../red/runtime/nodes/index");
|
||||
var flows = require("../../../../red/runtime/nodes/flows");
|
||||
var registry = require("../../../../red/runtime/nodes/registry");
|
||||
@@ -81,7 +80,7 @@ describe("red/nodes/index", function() {
|
||||
testnode.credentials.should.have.property('c',"2");
|
||||
testnode.credentials.should.have.property('d',"bar");
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -93,7 +92,7 @@ describe("red/nodes/index", function() {
|
||||
// console.log(index.getFlows());
|
||||
should.deepEqual(testFlows, index.getFlows().flows);
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
|
||||
@@ -258,7 +257,7 @@ describe("red/nodes/index", function() {
|
||||
info.should.eql(randomNodeInfo);
|
||||
done();
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -273,7 +272,7 @@ describe("red/nodes/index", function() {
|
||||
}).should.throw();
|
||||
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -288,7 +287,7 @@ describe("red/nodes/index", function() {
|
||||
}).should.throw();
|
||||
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -341,7 +340,7 @@ describe("red/nodes/index", function() {
|
||||
}).should.throw();
|
||||
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -356,7 +355,7 @@ describe("red/nodes/index", function() {
|
||||
}).should.throw();
|
||||
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
@@ -60,7 +60,7 @@ describe('red/nodes/registry/index', function() {
|
||||
registry.addModule("foo").then(function(info) {
|
||||
info.should.eql("info");
|
||||
done();
|
||||
}).otherwise(function(err) { done(err); });
|
||||
}).catch(function(err) { done(err); });
|
||||
});
|
||||
it('rejects if loader rejects', function(done) {
|
||||
stubs.push(sinon.stub(loader,"addModule",function(module) {
|
||||
@@ -71,7 +71,7 @@ describe('red/nodes/registry/index', function() {
|
||||
}));
|
||||
registry.addModule("foo").then(function(info) {
|
||||
done(new Error("unexpected resolve"));
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
err.should.eql("error");
|
||||
done();
|
||||
})
|
||||
@@ -90,7 +90,7 @@ describe('red/nodes/registry/index', function() {
|
||||
typeRegistry.enableNodeSet.called.should.be.true();
|
||||
ns.should.have.a.property('id','node-set');
|
||||
done();
|
||||
}).otherwise(function(err) { done(err); });
|
||||
}).catch(function(err) { done(err); });
|
||||
});
|
||||
|
||||
it('rejects if node unknown',function() {
|
||||
@@ -121,7 +121,7 @@ describe('red/nodes/registry/index', function() {
|
||||
ns.should.have.a.property('id','node-set');
|
||||
ns.should.have.a.property('loaded',true);
|
||||
done();
|
||||
}).otherwise(function(err) { done(err); });
|
||||
}).catch(function(err) { done(err); });
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -83,7 +83,7 @@ describe('nodes/registry/installer', function() {
|
||||
return ee;
|
||||
});
|
||||
|
||||
installer.installModule("this_wont_exist").otherwise(function(err) {
|
||||
installer.installModule("this_wont_exist").catch(function(err) {
|
||||
err.should.have.property("code",404);
|
||||
done();
|
||||
});
|
||||
@@ -105,7 +105,7 @@ describe('nodes/registry/installer', function() {
|
||||
}
|
||||
});
|
||||
|
||||
installer.installModule("this_wont_exist","0.1.2").otherwise(function(err) {
|
||||
installer.installModule("this_wont_exist","0.1.2").catch(function(err) {
|
||||
err.code.should.be.eql(404);
|
||||
done();
|
||||
});
|
||||
@@ -116,7 +116,7 @@ describe('nodes/registry/installer', function() {
|
||||
version: "0.1.1"
|
||||
}
|
||||
});
|
||||
installer.installModule("this_wont_exist","0.1.1").otherwise(function(err) {
|
||||
installer.installModule("this_wont_exist","0.1.1").catch(function(err) {
|
||||
err.code.should.be.eql('module_already_loaded');
|
||||
done();
|
||||
});
|
||||
@@ -135,7 +135,7 @@ describe('nodes/registry/installer', function() {
|
||||
|
||||
installer.installModule("this_wont_exist").then(function() {
|
||||
done(new Error("Unexpected success"));
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -160,7 +160,7 @@ describe('nodes/registry/installer', function() {
|
||||
// commsMessages[0].topic.should.equal("node/added");
|
||||
// commsMessages[0].msg.should.eql(nodeInfo.nodes);
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -169,7 +169,7 @@ describe('nodes/registry/installer', function() {
|
||||
var resourcesDir = path.resolve(path.join(__dirname,"..","resources","local","TestNodeModule","node_modules","NonExistant"));
|
||||
installer.installModule(resourcesDir).then(function() {
|
||||
done(new Error("Unexpected success"));
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
if (err.hasOwnProperty("code")) {
|
||||
err.code.should.eql(404);
|
||||
done();
|
||||
@@ -199,7 +199,7 @@ describe('nodes/registry/installer', function() {
|
||||
installer.installModule(resourcesDir).then(function(info) {
|
||||
info.should.eql(nodeInfo);
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -228,7 +228,7 @@ describe('nodes/registry/installer', function() {
|
||||
|
||||
installer.uninstallModule("this_wont_exist").then(function() {
|
||||
done(new Error("Unexpected success"));
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -252,7 +252,7 @@ describe('nodes/registry/installer', function() {
|
||||
// commsMessages[0].topic.should.equal("node/removed");
|
||||
// commsMessages[0].msg.should.eql(nodeInfo);
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
@@ -69,7 +69,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
loader.load("foo",true).then(function() {
|
||||
registry.saveNodeList.called.should.be.true();
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
})
|
||||
});
|
||||
@@ -118,7 +118,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
nodes.registerType.lastCall.args[1].should.eql('test-node-1');
|
||||
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -169,7 +169,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
nodes.registerType.secondCall.args[1].should.eql('test-node-multiple-1b');
|
||||
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -219,7 +219,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
nodes.registerType.lastCall.args[1].should.eql('test-node-2');
|
||||
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -267,7 +267,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
nodes.registerType.calledOnce.should.be.false();
|
||||
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -313,7 +313,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
nodes.registerType.calledOnce.should.be.false();
|
||||
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -360,7 +360,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
nodes.registerType.calledOnce.should.be.false();
|
||||
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -379,7 +379,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
stubs.push(sinon.stub(registry,"getModuleInfo",function(){return{}}));
|
||||
loader.init({nodes:nodes,i18n:{defaultLang:"en-US"},events:{on:function(){},removeListener:function(){}},log:{info:function(){},_:function(){}},settings:{available:function(){return true;}}});
|
||||
|
||||
loader.addModule("test-module").otherwise(function(err) {
|
||||
loader.addModule("test-module").catch(function(err) {
|
||||
err.code.should.eql("module_already_loaded");
|
||||
done();
|
||||
});
|
||||
@@ -390,7 +390,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
throw new Error("failure");
|
||||
}));
|
||||
loader.init({nodes:nodes,i18n:{defaultLang:"en-US"},events:{on:function(){},removeListener:function(){}},log:{info:function(){},_:function(){}},settings:{available:function(){return true;}}});
|
||||
loader.addModule("test-module").otherwise(function(err) {
|
||||
loader.addModule("test-module").catch(function(err) {
|
||||
err.message.should.eql("failure");
|
||||
done();
|
||||
});
|
||||
@@ -441,7 +441,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
|
||||
nodes.registerType.calledOnce.should.be.true();
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -477,7 +477,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
registry.addNodeSet.called.should.be.false();
|
||||
nodes.registerType.called.should.be.false();
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -498,7 +498,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
node.enabled.should.be.false();
|
||||
nodes.registerType.called.should.be.false();
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -517,7 +517,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
node.err.toString().should.eql("Error: fail to require (line:1)");
|
||||
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
@@ -292,7 +292,7 @@ describe("red/nodes/registry/registry",function() {
|
||||
it('rejects when settings unavailable',function(done) {
|
||||
typeRegistry.init(stubSettings({},false,{}));
|
||||
typeRegistry.addNodeSet("test-module/test-name",testNodeSet1, "0.0.1");
|
||||
typeRegistry.saveNodeList().otherwise(function(err) {
|
||||
typeRegistry.saveNodeList().catch(function(err) {
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -312,7 +312,7 @@ describe("red/nodes/registry/registry",function() {
|
||||
nn.should.not.have.property('id');
|
||||
}
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
var should = require("should");
|
||||
var when = require("when");
|
||||
|
||||
var settings = require("../../../red/runtime/settings");
|
||||
|
||||
@@ -86,12 +85,12 @@ describe("red/settings", function() {
|
||||
var saveCount = 0;
|
||||
var storage = {
|
||||
getSettings: function() {
|
||||
return when.resolve({globalA:789});
|
||||
return Promise.resolve({globalA:789});
|
||||
},
|
||||
saveSettings: function(settings) {
|
||||
saveCount++;
|
||||
savedSettings = settings;
|
||||
return when.resolve();
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
settings.init(userSettings);
|
||||
@@ -115,7 +114,7 @@ describe("red/settings", function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
@@ -47,7 +47,7 @@ describe('storage/localfilesystem', function() {
|
||||
fs.existsSync(path.join(userDir,"lib")).should.be.true();
|
||||
fs.existsSync(path.join(userDir,"lib",'flows')).should.be.true();
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -70,7 +70,7 @@ describe('storage/localfilesystem', function() {
|
||||
} finally {
|
||||
process.env.NODE_RED_HOME = oldNRH;
|
||||
}
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -96,7 +96,7 @@ describe('storage/localfilesystem', function() {
|
||||
process.env.NODE_RED_HOME = oldNRH;
|
||||
process.env.NODE_HOMEPATH = oldHOMEPATH;
|
||||
}
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -124,7 +124,7 @@ describe('storage/localfilesystem', function() {
|
||||
process.env.HOME = oldHOME;
|
||||
process.env.HOMEPATH = oldHOMEPATH;
|
||||
}
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -155,7 +155,7 @@ describe('storage/localfilesystem', function() {
|
||||
process.env.HOMEPATH = oldHOMEPATH;
|
||||
process.env.USERPROFILE = oldUSERPROFILE;
|
||||
}
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -168,10 +168,10 @@ describe('storage/localfilesystem', function() {
|
||||
localfilesystem.getFlows().then(function(flows) {
|
||||
flows.should.eql([]);
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -186,10 +186,10 @@ describe('storage/localfilesystem', function() {
|
||||
localfilesystem.getFlows().then(function(flows) {
|
||||
flows.should.eql([]);
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -208,11 +208,11 @@ describe('storage/localfilesystem', function() {
|
||||
localfilesystem.getFlows().then(function(flows) {
|
||||
flows.should.eql(testFlow);
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
},50);
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -230,13 +230,13 @@ describe('storage/localfilesystem', function() {
|
||||
localfilesystem.getFlows().then(function(flows) {
|
||||
flows.should.eql(testFlow);
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -257,13 +257,13 @@ describe('storage/localfilesystem', function() {
|
||||
localfilesystem.getFlows().then(function(flows) {
|
||||
flows.should.eql(testFlow);
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -278,13 +278,13 @@ describe('storage/localfilesystem', function() {
|
||||
localfilesystem.getFlows().then(function(flows) {
|
||||
flows.should.eql(testFlow);
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -298,11 +298,11 @@ describe('storage/localfilesystem', function() {
|
||||
fs.fsync.callCount.should.be.greaterThan(0);
|
||||
fs.fsync.restore();
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
fs.fsync.restore();
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -321,10 +321,10 @@ describe('storage/localfilesystem', function() {
|
||||
fs.fsync.callCount.should.be.greaterThan(0);
|
||||
fs.fsync.restore();
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -358,14 +358,14 @@ describe('storage/localfilesystem', function() {
|
||||
content2.should.not.equal(backupContent);
|
||||
done();
|
||||
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
|
||||
@@ -382,10 +382,10 @@ describe('storage/localfilesystem', function() {
|
||||
localfilesystem.getCredentials().then(function(creds) {
|
||||
creds.should.eql({});
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -406,13 +406,13 @@ describe('storage/localfilesystem', function() {
|
||||
localfilesystem.getCredentials().then(function(creds) {
|
||||
creds.should.eql(credentials);
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -437,10 +437,10 @@ describe('storage/localfilesystem', function() {
|
||||
fs.existsSync(credFile).should.be.true();
|
||||
fs.existsSync(credFileBackup).should.be.true();
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -463,13 +463,13 @@ describe('storage/localfilesystem', function() {
|
||||
localfilesystem.getCredentials().then(function(creds) {
|
||||
creds.should.eql(credentials);
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
@@ -38,7 +38,7 @@ describe('storage/localfilesystem/sessions', function() {
|
||||
localfilesystemSessions.getSessions().then(function(sessions) {
|
||||
sessions.should.eql({});
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -51,7 +51,7 @@ describe('storage/localfilesystem/sessions', function() {
|
||||
localfilesystemSessions.getSessions().then(function(sessions) {
|
||||
sessions.should.eql({});
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -69,10 +69,10 @@ describe('storage/localfilesystem/sessions', function() {
|
||||
localfilesystemSessions.getSessions().then(function(_sessions) {
|
||||
_sessions.should.eql(sessions);
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
@@ -39,7 +39,7 @@ describe('storage/localfilesystem/settings', function() {
|
||||
localfilesystemSettings.getSettings().then(function(settings) {
|
||||
settings.should.eql({});
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -52,7 +52,7 @@ describe('storage/localfilesystem/settings', function() {
|
||||
localfilesystemSettings.getSettings().then(function(settings) {
|
||||
settings.should.eql({});
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -70,10 +70,10 @@ describe('storage/localfilesystem/settings', function() {
|
||||
localfilesystemSettings.getSettings().then(function(_settings) {
|
||||
_settings.should.eql(settings);
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).otherwise(function(err) {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user