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

Fix email tests and add one for MTA node

This commit is contained in:
Dave Conway-Jones 2020-10-19 14:32:09 +01:00
parent 14087a9f77
commit ef1ebe7b44
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
2 changed files with 58 additions and 2 deletions

View File

@ -518,7 +518,7 @@ module.exports = function(RED) {
});
function emailMtaNode(n) {
function EmailMtaNode(n) {
RED.nodes.createNode(this,n);
this.port = n.port;
var node = this;
@ -573,6 +573,6 @@ module.exports = function(RED) {
node.mta.close();
});
}
RED.nodes.registerType("e-mail mta",emailMtaNode);
RED.nodes.registerType("e-mail mta",EmailMtaNode);
};

View File

@ -43,6 +43,7 @@ describe('email Node', function () {
id: "n1",
type: "e-mail",
name: "emailout",
port: 1025,
wires: [
[]
]
@ -188,4 +189,59 @@ describe('email Node', function () {
})
});
describe('email mta', function () {
it('should catch an email send to localhost 1025', function (done) {
var flow = [{
id: "n1",
type: "e-mail mta",
name: "emailmta",
port: 1025,
wires: [
["n2"]
]
},
{
id:"n2",
type:"helper"
},
{
id: "n3",
type: "e-mail",
dname: "testout",
server: "localhost",
secure: false,
port: 1025,
wires: [
[]
]
}];
helper.load(emailNode, flow, function () {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
var n3 = helper.getNode("n3");
n1.should.have.property('port', 1025);
n2.on("input", function(msg) {
//console.log("GOT",msg);
msg.should.have.a.property("payload",'Hello World\n');
msg.should.have.a.property("topic","Test");
msg.should.have.a.property("from",'foo@example.com');
msg.should.have.a.property("to",'bar@example.com');
msg.should.have.a.property("attachments");
msg.should.have.a.property("header");
done();
});
n3.emit("input", {
payload: "Hello World",
topic: "Test",
from: "foo@example.com",
to: "bar@example.com"
});
//done();
});
});
});
});