added test and fixed changing passed in object within ctor
This commit is contained in:
parent
d4bd2bca28
commit
ba48d042b8
|
@ -18,15 +18,20 @@ module.exports = MailConnector;
|
|||
*/
|
||||
|
||||
function MailConnector(settings) {
|
||||
|
||||
assert(typeof settings === 'object', 'cannot initialize MailConnector without a settings object');
|
||||
|
||||
if(!settings.transport){
|
||||
settings.transport = [];
|
||||
}else{
|
||||
settings.transport = [settings.transport];
|
||||
var transports = settings.transports;
|
||||
|
||||
//if transports is not in settings object AND settings.transport exists
|
||||
if(!transports && settings.transport){
|
||||
//then wrap single transport in an array and assign to transports
|
||||
transports = [settings.transport];
|
||||
}
|
||||
|
||||
var transports = settings.transports || settings.transport;
|
||||
if(!transports){
|
||||
transports = [];
|
||||
}
|
||||
|
||||
this.transportsIndex = {};
|
||||
this.transports = [];
|
||||
|
|
|
@ -24,6 +24,17 @@ describe('Email connector', function () {
|
|||
]});
|
||||
assert(connector.transportForName('stub'));
|
||||
});
|
||||
|
||||
|
||||
it('should set up a single transport for SMTP' , function () {
|
||||
var connector = new MailConnector({transport:
|
||||
{type: 'smtp', service: 'gmail'}
|
||||
});
|
||||
|
||||
assert(connector.transportForName('smtp'));
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe('Email and SMTP', function () {
|
||||
|
@ -74,3 +85,5 @@ describe('Email and SMTP', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue