1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fix incorrect async test completion

This commit is contained in:
Nick O'Leary 2015-11-14 20:27:04 +00:00
parent 45f67191ba
commit a92a741932
3 changed files with 28 additions and 21 deletions

View File

@ -77,7 +77,6 @@ describe('JSON node', function() {
var jn1 = helper.getNode("jn1");
var jn2 = helper.getNode("jn2");
jn2.on("input", function(msg) {
console.log(msg);
should.equal(msg.payload, '[1,2,3]');
done();
});
@ -118,7 +117,6 @@ describe('JSON node', function() {
var logEvents = helper.log().args.filter(function(evt) {
return evt[0].type == "json";
});
console.log(logEvents);
logEvents.should.have.length(3);
logEvents[0][0].should.have.a.property('msg');
logEvents[0][0].msg.toString().should.eql('json.errors.dropped');

View File

@ -124,13 +124,16 @@ describe("red/nodes/index", function() {
});
after(function(done) {
fs.remove(userDir,done);
runtime.stop();
fs.remove(userDir,function() {;
runtime.stop().then(function() {
index.load.restore();
localfilesystem.getCredentials.restore();
done();
});
});
});
it(': definition defined',function(done) {
it(': definition defined',function() {
index.registerType('test', TestNode, {
credentials: {
foo: {type:"test"}
@ -138,13 +141,11 @@ describe("red/nodes/index", function() {
});
var testnode = new TestNode({id:'tab1',type:'test',name:'barney', '_alias':'tab1'});
index.getCredentialDefinition("test").should.have.property('foo');
done();
});
});
describe('allows nodes to be added/removed/enabled/disabled from the registry', function() {
var registry = require("../../../../red/runtime/nodes/registry");
var randomNodeInfo = {id:"5678",types:["random"]};
beforeEach(function() {

View File

@ -18,6 +18,7 @@ var should = require("should");
var sinon = require("sinon");
var when = require("when");
var path = require("path");
var fs = require('fs');
var child_process = require('child_process');
var installer = require("../../../../../red/runtime/nodes/registry/installer");
@ -33,7 +34,24 @@ describe('nodes/registry/installer', function() {
if (child_process.execFile.restore) {
child_process.execFile.restore();
}
})
if (registry.addModule.restore) {
registry.addModule.restore();
}
if (registry.removeModule.restore) {
registry.removeModule.restore();
}
if (typeRegistry.removeModule.restore) {
typeRegistry.removeModule.restore();
}
if (registry.getModuleInfo.restore) {
registry.getModuleInfo.restore();
}
if (require('fs').existsSync.restore) {
require('fs').existsSync.restore();
}
});
describe("installs module", function() {
it("rejects when npm returns a 404", function(done) {
@ -74,8 +92,6 @@ describe('nodes/registry/installer', function() {
done();
}).otherwise(function(err) {
done(err);
}).finally(function() {
addModule.restore();
});
});
it("rejects when non-existant path is provided", function(done) {
@ -101,8 +117,6 @@ describe('nodes/registry/installer', function() {
done();
}).otherwise(function(err) {
done(err);
}).finally(function() {
addModule.restore();
});
});
@ -132,8 +146,6 @@ describe('nodes/registry/installer', function() {
done(new Error("Unexpected success"));
}).otherwise(function(err) {
done();
}).finally(function() {
removeModule.restore();
});
});
it("succeeds when module is found", function(done) {
@ -148,7 +160,7 @@ describe('nodes/registry/installer', function() {
cb(null,"","");
});
var exists = sinon.stub(require('fs'),"existsSync", function(fn) { return true; });
var exists = sinon.stub(fs,"existsSync", function(fn) { return true; });
installer.uninstallModule("this_wont_exist").then(function(info) {
info.should.eql(nodeInfo);
@ -158,10 +170,6 @@ describe('nodes/registry/installer', function() {
done();
}).otherwise(function(err) {
done(err);
}).finally(function() {
removeModule.restore();
exists.restore();
getModuleInfo.restore();
});
});
});