smartsmtp/test/test.ts

46 lines
1.4 KiB
TypeScript
Raw Normal View History

2020-08-12 14:13:20 +00:00
import { expect, tap } from '@pushrocks/tapbundle';
2022-08-07 14:37:19 +00:00
import * as smartsmtp from '../ts/index.js';
2020-08-12 14:13:20 +00:00
import { Qenv } from '@pushrocks/qenv';
import * as smartmail from '@pushrocks/smartmail';
const testQenv = new Qenv('./', './.nogit');
let testSmartsmtp: smartsmtp.Smartsmtp;
tap.test('should create a valid instance of Smartsmtp', async () => {
testSmartsmtp = await smartsmtp.Smartsmtp.createSmartsmtpWithRelay({
2020-08-12 14:13:20 +00:00
smtpServer: testQenv.getEnvVarOnDemand('SMTP_SERVER'),
smtpUser: testQenv.getEnvVarOnDemand('SMTP_USER'),
smtpPassword: testQenv.getEnvVarOnDemand('SMTP_PASSWORD'),
});
2022-08-07 14:37:19 +00:00
expect(testSmartsmtp).toBeInstanceOf(smartsmtp.Smartsmtp);
2020-08-12 14:13:20 +00:00
});
tap.test('should send a message with empty body', async () => {
2020-08-12 15:09:41 +00:00
const result = await testSmartsmtp.sendSmartMail(
new smartmail.Smartmail({
body: '',
from: 'smartsmtp@mail.lossless.one',
subject: 'this is a test message',
}),
'sandbox@mail.git.zone'
);
2020-08-12 14:13:20 +00:00
console.log(result);
});
tap.test('should create a direct smartsmtp transport', async () => {
const smartsmtpInstance = await smartsmtp.Smartsmtp.createSmartsmtpSendmail();
const result = await smartsmtpInstance.sendSmartMail(
new smartmail.Smartmail({
body: 'hi there',
from: 'phil@lossless.com',
subject: 'this is a sendmail test message',
}),
'phil@kunz.io'
);
console.log(result);
2022-08-07 16:23:53 +00:00
});
2020-08-12 14:13:20 +00:00
tap.start();