mirror of
https://github.com/eleith/emailjs.git
synced 2024-07-04 19:58:51 +00:00
49 lines
1.0 KiB
TypeScript
49 lines
1.0 KiB
TypeScript
import test from 'ava';
|
|
|
|
import { client as c, message as m, SMTP } from '../email';
|
|
|
|
test.cb(
|
|
'connecting to wrong email server should not invoke callback multiple times',
|
|
(t) => {
|
|
t.timeout(5000);
|
|
|
|
const client = new c.Client({ host: 'bar.baz' });
|
|
const msg = {
|
|
from: 'foo@bar.baz',
|
|
to: 'foo@bar.baz',
|
|
subject: 'hello world',
|
|
text: 'hello world',
|
|
};
|
|
client.send(new m.Message(msg), (err) => {
|
|
t.not(err, null);
|
|
t.end();
|
|
});
|
|
}
|
|
);
|
|
|
|
test('should have a default timeout', async (t) => {
|
|
const connectionOptions = {
|
|
user: 'username',
|
|
password: 'password',
|
|
host: '127.0.0.1',
|
|
port: 1234,
|
|
timeout: undefined as number | null | undefined,
|
|
};
|
|
t.deepEqual(
|
|
new c.Client(connectionOptions).smtp.timeout,
|
|
SMTP.DEFAULT_TIMEOUT
|
|
);
|
|
|
|
connectionOptions.timeout = null;
|
|
t.deepEqual(
|
|
new c.Client(connectionOptions).smtp.timeout,
|
|
SMTP.DEFAULT_TIMEOUT
|
|
);
|
|
|
|
connectionOptions.timeout = undefined;
|
|
t.deepEqual(
|
|
new c.Client(connectionOptions).smtp.timeout,
|
|
SMTP.DEFAULT_TIMEOUT
|
|
);
|
|
});
|