fix(build): modernize package configuration, dependencies, and test setup for current toolchain compatibility
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
import * as smartsmtp from '../ts/index.js';
|
||||
|
||||
import { Qenv } from '@push.rocks/qenv';
|
||||
import * as smartmail from '@push.rocks/smartmail';
|
||||
|
||||
const testQenv = new Qenv('./', './.nogit');
|
||||
|
||||
let testSmartsmtp: smartsmtp.Smartsmtp;
|
||||
|
||||
const requireEnv = async (envNameArg: string): Promise<string> => {
|
||||
const envValue = await testQenv.getEnvVarOnDemand(envNameArg);
|
||||
if (!envValue) {
|
||||
throw new Error(`Missing required environment variable: ${envNameArg}`);
|
||||
}
|
||||
return envValue;
|
||||
};
|
||||
|
||||
tap.test('should create a direct smartsmtp transport', async () => {
|
||||
const smartsmtpInstance = await smartsmtp.Smartsmtp.createSmartsmtpSendmail();
|
||||
expect(smartsmtpInstance).toBeInstanceOf(smartsmtp.Smartsmtp);
|
||||
});
|
||||
|
||||
tap.test('should run SMTP integration flow', async () => {
|
||||
if (process.env.SMARTSMTP_RUN_INTEGRATION_TESTS !== 'true') {
|
||||
console.log('Skipping SMTP integration test. Set SMARTSMTP_RUN_INTEGRATION_TESTS=true to run it.');
|
||||
return;
|
||||
}
|
||||
|
||||
testSmartsmtp = await smartsmtp.Smartsmtp.createSmartsmtpWithRelay({
|
||||
smtpServer: await requireEnv('SMTP_SERVER'),
|
||||
smtpUser: await requireEnv('SMTP_USER'),
|
||||
smtpPassword: await requireEnv('SMTP_PASSWORD'),
|
||||
});
|
||||
expect(testSmartsmtp).toBeInstanceOf(smartsmtp.Smartsmtp);
|
||||
|
||||
const result = await testSmartsmtp.sendSmartMail(
|
||||
new smartmail.Smartmail({
|
||||
body: '',
|
||||
from: 'smartsmtp@mail.lossless.one',
|
||||
subject: 'this is a test message',
|
||||
}),
|
||||
'sandbox@mail.git.zone'
|
||||
);
|
||||
console.log(result);
|
||||
});
|
||||
|
||||
tap.test('should run sendmail integration flow', async () => {
|
||||
if (process.env.SMARTSMTP_RUN_SENDMAIL_TESTS !== 'true') {
|
||||
console.log('Skipping sendmail integration test. Set SMARTSMTP_RUN_SENDMAIL_TESTS=true to run it.');
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
@@ -1,45 +0,0 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as smartsmtp from '../ts/index.js';
|
||||
|
||||
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({
|
||||
smtpServer: testQenv.getEnvVarOnDemand('SMTP_SERVER'),
|
||||
smtpUser: testQenv.getEnvVarOnDemand('SMTP_USER'),
|
||||
smtpPassword: testQenv.getEnvVarOnDemand('SMTP_PASSWORD'),
|
||||
});
|
||||
expect(testSmartsmtp).toBeInstanceOf(smartsmtp.Smartsmtp);
|
||||
});
|
||||
|
||||
tap.test('should send a message with empty body', async () => {
|
||||
const result = await testSmartsmtp.sendSmartMail(
|
||||
new smartmail.Smartmail({
|
||||
body: '',
|
||||
from: 'smartsmtp@mail.lossless.one',
|
||||
subject: 'this is a test message',
|
||||
}),
|
||||
'sandbox@mail.git.zone'
|
||||
);
|
||||
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);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
Reference in New Issue
Block a user