import { tap, expect } from '@git.zone/tstest/tapbundle'; import { startTestServer, stopTestServer, type ITestServer } from '../../helpers/server.loader.js'; import { createSmtpClient } from '../../../ts/mail/delivery/smtpclient/index.js'; import { Email } from '../../../ts/mail/core/classes.email.js'; let testServer: ITestServer; tap.test('setup test SMTP server', async () => { testServer = await startTestServer({ port: 2579, tlsEnabled: false, authRequired: false }); expect(testServer).toBeTruthy(); expect(testServer.port).toEqual(2579); }); tap.test('CEP-06: Basic UTF-8 characters', async () => { console.log('Testing basic UTF-8 characters'); const smtpClient = createSmtpClient({ host: testServer.hostname, port: testServer.port, secure: false, connectionTimeout: 5000, debug: true }); // Email with basic UTF-8 characters const email = new Email({ from: 'sender@example.com', to: ['recipient@example.com'], subject: 'UTF-8 Test: café, naïve, résumé', text: 'This email contains UTF-8 characters: café, naïve, résumé, piñata', html: '
HTML with UTF-8: café, naïve, résumé, piñata
' }); const result = await smtpClient.sendMail(email); expect(result).toBeDefined(); expect(result.messageId).toBeDefined(); console.log('Successfully sent email with basic UTF-8 characters'); await smtpClient.close(); }); tap.test('CEP-06: European characters', async () => { console.log('Testing European characters'); const smtpClient = createSmtpClient({ host: testServer.hostname, port: testServer.port, secure: false, connectionTimeout: 5000, debug: true }); // Email with European characters const email = new Email({ from: 'sender@example.com', to: ['recipient@example.com'], subject: 'European: ñ, ü, ø, å, ß, æ', text: [ 'German: Müller, Größe, Weiß', 'Spanish: niño, señor, España', 'French: français, crème, être', 'Nordic: København, Göteborg, Ålesund', 'Polish: Kraków, Gdańsk, Wrocław' ].join('\n'), html: `Chinese (Simplified): | 你好世界 |
Chinese (Traditional): | 你好世界 |
Japanese: | こんにちは世界 |
Korean: | 안녕하세요 세계 |
Thai: | สวัสดีโลก |
Hindi: | नमस्ते संसार |
Faces: 😀 😃 😄 😁 😆 😅 😂
Objects: 🎉 🚀 ✨ 🌈 ⭐ 🔥 💎
Animals: 🐶 🐱 🐭 🐹 🐰 🦊 🐻
Food: 🍎 🍌 🍇 🍓 🥝 🍅 🥑
Symbols: ✓ ✗ ⚠ ♠ ♣ ♥ ♦
Math: ∑ ∏ ∫ ∞ ± × ÷ ≠ ≤ ≥
` }); const result = await smtpClient.sendMail(email); expect(result).toBeDefined(); expect(result.messageId).toBeDefined(); console.log('Successfully sent email with emojis and symbols'); await smtpClient.close(); }); tap.test('CEP-06: Mixed international content', async () => { console.log('Testing mixed international content'); const smtpClient = createSmtpClient({ host: testServer.hostname, port: testServer.port, secure: false, connectionTimeout: 5000, debug: true }); // Email with mixed international content const email = new Email({ from: 'sender@example.com', to: ['recipient@example.com'], subject: 'Mixed: Hello 你好 مرحبا こんにちは 🌍', text: [ 'English: Hello World!', 'Chinese: 你好世界!', 'Arabic: مرحبا بالعالم!', 'Japanese: こんにちは世界!', 'Russian: Привет мир!', 'Greek: Γεια σας κόσμε!', 'Mixed: Hello 世界 🌍 مرحبا こんにちは!' ].join('\n'), html: `English: Hello World!
Chinese: 你好世界!
Arabic: مرحبا بالعالم!
Japanese: こんにちは世界!
Russian: Привет мир!
Greek: Γεια σας κόσμε!
Mixed: Hello 世界 🌍 مرحبا こんにちは!