Fixup all the tests

This commit is contained in:
Nick O'Leary
2018-04-24 15:01:49 +01:00
parent 34832d5942
commit 5d064aa1d7
50 changed files with 3480 additions and 1762 deletions

View File

@@ -110,7 +110,7 @@ describe('Node', function() {
p.then(function() {
callbacksClosed.should.eql(3);
testdone();
}).otherwise(function(e) {
}).catch(function(e) {
testdone(e);
});
});

View File

@@ -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();
});

View File

@@ -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);
})
});

View File

@@ -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);
});
});

View File

@@ -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); });
});
});

View File

@@ -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);
});
});

View File

@@ -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);
});
});

View File

@@ -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);
});
});