67 lines
2.2 KiB
TypeScript
67 lines
2.2 KiB
TypeScript
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
|
import { createTestServer } from '../../helpers/server.loader.js';
|
|
import { createTestSmtpClient } from '../../helpers/smtp.client.js';
|
|
import { Email } from '../../../ts/mail/core/classes.email.js';
|
|
|
|
tap.test('CRFC-03: SMTP Command Syntax Compliance', async () => {
|
|
console.log('\n📧 Testing SMTP Client Command Syntax Compliance');
|
|
console.log('=' .repeat(60));
|
|
|
|
const testServer = await createTestServer({});
|
|
|
|
try {
|
|
const smtpClient = createTestSmtpClient({
|
|
host: testServer.hostname,
|
|
port: testServer.port
|
|
});
|
|
|
|
console.log('\nTest 1: Valid email addresses');
|
|
const email1 = new Email({
|
|
from: 'sender@example.com',
|
|
to: ['recipient@example.com'],
|
|
subject: 'Valid email test',
|
|
text: 'Testing valid email addresses'
|
|
});
|
|
|
|
const result1 = await smtpClient.sendMail(email1);
|
|
console.log(' ✓ Valid email addresses accepted');
|
|
expect(result1).toBeDefined();
|
|
|
|
console.log('\nTest 2: Email with display names');
|
|
const email2 = new Email({
|
|
from: 'Test Sender <sender@example.com>',
|
|
to: ['Test Recipient <recipient@example.com>'],
|
|
subject: 'Display name test',
|
|
text: 'Testing email addresses with display names'
|
|
});
|
|
|
|
const result2 = await smtpClient.sendMail(email2);
|
|
console.log(' ✓ Display names handled correctly');
|
|
expect(result2).toBeDefined();
|
|
|
|
console.log('\nTest 3: Multiple recipients');
|
|
const email3 = new Email({
|
|
from: 'sender@example.com',
|
|
to: ['user1@example.com', 'user2@example.com'],
|
|
cc: ['cc@example.com'],
|
|
subject: 'Multiple recipients test',
|
|
text: 'Testing RCPT TO command with multiple recipients'
|
|
});
|
|
|
|
const result3 = await smtpClient.sendMail(email3);
|
|
console.log(' ✓ Multiple RCPT TO commands sent correctly');
|
|
expect(result3).toBeDefined();
|
|
|
|
console.log('\nTest 4: Connection test (HELO/EHLO)');
|
|
const verified = await smtpClient.verify();
|
|
console.log(' ✓ HELO/EHLO command syntax correct');
|
|
expect(verified).toBeDefined();
|
|
|
|
console.log('\n✅ CRFC-03: Command syntax compliance tests completed');
|
|
|
|
} finally {
|
|
testServer.server.close();
|
|
}
|
|
});
|
|
|
|
tap.start(); |