Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Andris Reinman committed Feb 20, 2012
1 parent cc9fb6f commit 14579d7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/transport.js
Expand Up @@ -68,6 +68,8 @@ Transport.prototype.close = function(callback){
if(typeof this.transport.close == "function"){
this.transport.close(callback);
}else{
callback(null);
if(typeof callback == "function"){
callback(null);
}
}
};
51 changes: 51 additions & 0 deletions test/nodemailer.js
Expand Up @@ -8,4 +8,55 @@ exports["General tests"] = {
var mail = new nodemailer.Nodemailer();
test.done();
}
}

exports["Transport close"] = {
"SMTP - Callback in transport.close": function(test){
var transport = nodemailer.createTransport("SMTP", {});
transport.close(function(){
test.ok(true);
test.done();
});
},

"SMTP - No callback in transport.close": function(test){
var transport = nodemailer.createTransport("SMTP", {});
transport.close();
process.nextTick(function(){
test.ok(true);
test.done();
});
},
"Sendmail - Callback in transport.close": function(test){
var transport = nodemailer.createTransport("Sendmail", {});
transport.close(function(){
test.ok(true);
test.done();
});
},

"Sendmail - No callback in transport.close": function(test){
var transport = nodemailer.createTransport("Sendmail", {});
transport.close();
process.nextTick(function(){
test.ok(true);
test.done();
});
},
"SES - Callback in transport.close": function(test){
var transport = nodemailer.createTransport("SES", {});
transport.close(function(){
test.ok(true);
test.done();
});
},

"SES - No callback in transport.close": function(test){
var transport = nodemailer.createTransport("SES", {});
transport.close();
process.nextTick(function(){
test.ok(true);
test.done();
});
}
}

0 comments on commit 14579d7

Please sign in to comment.