Files
mailer/test/test.integration.ts
Juergen Kunz 17f5661636
Some checks failed
CI / Type Check & Lint (push) Failing after 3s
CI / Build Test (Current Platform) (push) Failing after 3s
CI / Build All Platforms (push) Failing after 3s
feat(storage): add comprehensive tests for StorageManager with memory, filesystem, and custom function backends
feat(email): implement EmailSendJob class for robust email delivery with retry logic and MX record resolution

feat(mail): restructure mail module exports for simplified access to core and delivery functionalities
2025-10-28 19:46:17 +00:00

75 lines
2.1 KiB
TypeScript

import { tap, expect } from '@git.zone/tstest/tapbundle';
import * as plugins from '../ts/plugins.ts';
// SzPlatformService doesn't exist in codebase - using DcRouter instead for integration tests
import DcRouter from '../ts/classes.dcrouter.ts';
import { BounceManager } from '../ts/mail/core/classes.bouncemanager.ts';
import { smtpClientMod } from '../ts/mail/delivery/index.ts';
import { SmtpServer } from '../ts/mail/delivery/smtpserver/smtp-server.ts';
// Test the new integration architecture
tap.test('should be able to create an SMTP server', async (tools) => {
// Create an SMTP server
const smtpServer = new SmtpServer({
options: {
port: 10025,
hostname: 'test.example.com',
key: '',
cert: ''
}
});
// Verify it was created properly
expect(smtpServer).toBeTruthy();
expect(smtpServer.options.port).toEqual(10025);
expect(smtpServer.options.hostname).toEqual('test.example.com');
});
tap.test('DcRouter should support email configuration', async (tools) => {
// Create a DcRouter with email config
const dcRouter = new DcRouter({
emailConfig: {
useEmail: true,
domainRules: [{
// name: 'test-rule', // not part of IDomainRule
match: {
senderPattern: '.*@test.com',
},
actions: []
}]
}
});
// Verify it was created properly
expect(dcRouter).toBeTruthy();
});
tap.test('SMTP client should be able to connect to SMTP server', async (tools) => {
// Create an SMTP client
const options = {
host: 'smtp.test.com',
port: 587,
secure: false,
auth: {
user: 'test@example.com',
pass: 'testpass'
},
connectionTimeout: 5000,
socketTimeout: 5000
};
const smtpClient = smtpClientMod.createSmtpClient(options);
// Verify it was created properly
expect(smtpClient).toBeTruthy();
// Since options are not exposed, just verify the client was created
expect(typeof smtpClient.sendMail).toEqual('function');
expect(typeof smtpClient.getPoolStatus).toEqual('function');
});
tap.test('stop', async () => {
await tap.stopForcefully();
});
// Export for tapbundle execution
export default tap.start();