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

Re-enable email node basic tests...

it’s a start….
This commit is contained in:
Dave Conway-Jones 2015-06-19 16:54:07 +01:00
parent 56bb10642a
commit fc05ddd035
2 changed files with 48 additions and 48 deletions

View File

@ -127,8 +127,8 @@ module.exports = function(RED) {
RED.nodes.createNode(this,n);
this.name = n.name;
this.repeat = n.repeat * 1000 || 300000;
this.inserver = n.server || globalkeys.server || "imap.gmail.com";
this.inport = n.port || globalkeys.port || "993";
this.inserver = n.server || (globalkeys && globalkeys.server) || "imap.gmail.com";
this.inport = n.port || (globalkeys && globalkeys.port) || "993";
this.box = n.box || "INBOX";
var flag = false;

View File

@ -30,56 +30,13 @@ describe('email Node', function() {
helper.stopServer(done);
});
describe.skip('email out', function() {
describe('email in', function() {
it('should load with defaults', function(done) {
var flow = [ { id:"n1", type:"e-mail", name:"emailout", wires:[[]] } ];
helper.load(emailNode, flow, function() {
var n1 = helper.getNode("n1");
n1.should.have.property('name', "emailout");
done();
});
});
it('should send an email', function(done) {
var smtpTransport = require("nodemailer").createTransport();
//var spy = sinon.stub(smtpTransport, 'sendMail', function(arg1,arg2,arg3,arg4) {
//console.log("HELLO");
//console.log(arg1,arg2,arg3,arg4);
//done();
//});
var flow = [ { id:"n1", type:"e-mail", name:"emailout", outserver:"smtp.gmail.com", outport:"465", wires:[[]] } ];
helper.load(emailNode, flow, function() {
var n1 = helper.getNode("n1");
n1.should.have.property('name', "emailout");
n1.emit("input", {payload:"Hello World"});
//done();
});
setTimeout(function() {
try {
var logEvents = helper.log().args.filter(function(evt) {
return evt[0].type == "e-mail";
});
//console.log(logEvents);
logEvents.should.have.length(1);
logEvents[0][0].should.have.a.property('msg');
logEvents[0][0].msg.toString().should.startWith("Error: connect ECONNREFUSED");
done();
}
catch(e) { done(e); }
//finally { smtpTransport.sendMail.restore(); }
},150);
})
});
describe.skip('email in', function() {
it('should load with defaults', function(done) {
var flow = [ { id:"n1", type:"e-mail in", wires:[["n2"]] },
{id:"n2", type:"helper"} ];
var flow = [ { id:"n1", type:"e-mail in", name:"emailin", wires:[[]] } ];
helper.load(emailNode, flow, function() {
var n1 = helper.getNode("n1");
n1.should.have.property('name', "emailin");
n1.should.have.property("repeat", 300000);
n1.should.have.property("inserver", "imap.gmail.com");
n1.should.have.property("inport", "993");
@ -104,4 +61,47 @@ describe('email Node', function() {
});
describe('email out', function() {
it('should load with defaults', function(done) {
var flow = [ { id:"n1", type:"e-mail", name:"emailout", wires:[[]] } ];
helper.load(emailNode, flow, function() {
var n1 = helper.getNode("n1");
n1.should.have.property('name', "emailout");
done();
});
});
it('should fail to send an email (no valid creds)', function(done) {
var smtpTransport = require("nodemailer").createTransport();
//var spy = sinon.stub(smtpTransport, 'sendMail', function(arg1,arg2,arg3,arg4) {
//console.log("HELLO");
//console.log(arg1,arg2,arg3,arg4);
//done();
//});
var flow = [ { id:"n1", type:"e-mail", name:"emailout", outserver:"smtp.gmail.com", outport:"465", wires:[[]] } ];
helper.load(emailNode, flow, function() {
var n1 = helper.getNode("n1");
n1.should.have.property('name', "emailout");
n1.emit("input", {payload:"Hello World"});
//done();
});
setTimeout(function() {
try {
var logEvents = helper.log().args.filter(function(evt) {
return evt[0].type == "e-mail";
});
//console.log(logEvents);
logEvents.should.have.length(3);
logEvents[2][0].should.have.a.property('msg');
logEvents[2][0].msg.toString().should.startWith("Error: connect ECONNREFUSED");
done();
}
catch(e) { done(e); }
//finally { smtpTransport.sendMail.restore(); }
},150);
})
});
});