1
0
mirror of https://github.com/eleith/emailjs.git synced 2024-07-07 12:40:37 +00:00
emailjs/test/server.ts

49 lines
1.0 KiB
TypeScript
Raw Normal View History

2020-04-21 03:20:42 +00:00
import test from 'ava';
import { client as c, message as m, SMTP } from '../email';
2020-04-23 04:26:49 +00:00
test.cb(
'connecting to wrong email server should not invoke callback multiple times',
(t) => {
t.timeout(5000);
2020-04-21 03:20:42 +00:00
2020-04-23 04:26:49 +00:00
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();
});
}
);
2020-04-21 03:20:42 +00:00
2020-04-23 04:26:49 +00:00
test('should have a default timeout', async (t) => {
2020-04-21 03:20:42 +00:00
const connectionOptions = {
user: 'username',
password: 'password',
host: '127.0.0.1',
port: 1234,
2020-04-23 04:26:49 +00:00
timeout: undefined as number | null | undefined,
2020-04-21 03:20:42 +00:00
};
2020-04-23 04:26:49 +00:00
t.deepEqual(
new c.Client(connectionOptions).smtp.timeout,
SMTP.DEFAULT_TIMEOUT
);
2020-04-21 03:20:42 +00:00
connectionOptions.timeout = null;
2020-04-23 04:26:49 +00:00
t.deepEqual(
new c.Client(connectionOptions).smtp.timeout,
SMTP.DEFAULT_TIMEOUT
);
2020-04-21 03:20:42 +00:00
connectionOptions.timeout = undefined;
2020-04-23 04:26:49 +00:00
t.deepEqual(
new c.Client(connectionOptions).smtp.timeout,
SMTP.DEFAULT_TIMEOUT
);
2020-04-21 03:20:42 +00:00
});