mirror of
https://github.com/eleith/emailjs.git
synced 2024-07-05 20:10:37 +00:00
ensure timeout is set to default value (fixes #225)
This commit is contained in:
parent
59265f9d95
commit
da4c83d090
@ -51,6 +51,10 @@ class SMTP extends EventEmitter {
|
||||
constructor(options = {}) {
|
||||
super();
|
||||
|
||||
if (options.timeout == null) {
|
||||
options.timeout = TIMEOUT;
|
||||
}
|
||||
|
||||
const {
|
||||
timeout,
|
||||
user,
|
||||
@ -63,7 +67,6 @@ class SMTP extends EventEmitter {
|
||||
authentication,
|
||||
} = Object.assign(
|
||||
{
|
||||
timeout: TIMEOUT,
|
||||
domain: os.hostname(),
|
||||
host: 'localhost',
|
||||
ssl: false,
|
||||
@ -640,3 +643,4 @@ class SMTP extends EventEmitter {
|
||||
exports.SMTP = SMTP;
|
||||
exports.state = SMTPState;
|
||||
exports.authentication = AUTH_METHODS;
|
||||
exports.DEFAULT_TIMEOUT = TIMEOUT;
|
||||
|
@ -28,4 +28,23 @@ describe('Connect to wrong email server', function() {
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should have a default timeout', function(done) {
|
||||
const connectionOptions = {
|
||||
user: "username",
|
||||
password: "password",
|
||||
host: "127.0.0.1",
|
||||
port: 1234,
|
||||
};
|
||||
|
||||
assert.strictEqual(email.server.connect(connectionOptions).smtp.timeout, email.SMTP.DEFAULT_TIMEOUT);
|
||||
|
||||
connectionOptions.timeout = null;
|
||||
assert.strictEqual(email.server.connect(connectionOptions).smtp.timeout, email.SMTP.DEFAULT_TIMEOUT);
|
||||
|
||||
connectionOptions.timeout = undefined;
|
||||
assert.strictEqual(email.server.connect(connectionOptions).smtp.timeout, email.SMTP.DEFAULT_TIMEOUT);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user