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: `

European Characters Test

` }); const result = await smtpClient.sendMail(email); expect(result).toBeDefined(); expect(result.messageId).toBeDefined(); console.log('Successfully sent email with European characters'); await smtpClient.close(); }); tap.test('CEP-06: Asian characters', async () => { console.log('Testing Asian characters'); const smtpClient = createSmtpClient({ host: testServer.hostname, port: testServer.port, secure: false, connectionTimeout: 5000, debug: true }); // Email with Asian characters const email = new Email({ from: 'sender@example.com', to: ['recipient@example.com'], subject: 'Asian: 你好, こんにちは, 안녕하세요', text: [ 'Chinese (Simplified): 你好世界', 'Chinese (Traditional): 你好世界', 'Japanese: こんにちは世界', 'Korean: 안녕하세요 세계', 'Thai: สวัสดีโลก', 'Hindi: नमस्ते संसार' ].join('\n'), html: `

Asian Characters Test

Chinese (Simplified):你好世界
Chinese (Traditional):你好世界
Japanese:こんにちは世界
Korean:안녕하세요 세계
Thai:สวัสดีโลก
Hindi:नमस्ते संसार
` }); const result = await smtpClient.sendMail(email); expect(result).toBeDefined(); expect(result.messageId).toBeDefined(); console.log('Successfully sent email with Asian characters'); await smtpClient.close(); }); tap.test('CEP-06: Emojis and symbols', async () => { console.log('Testing emojis and symbols'); const smtpClient = createSmtpClient({ host: testServer.hostname, port: testServer.port, secure: false, connectionTimeout: 5000, debug: true }); // Email with emojis and symbols const email = new Email({ from: 'sender@example.com', to: ['recipient@example.com'], subject: 'Emojis: 🎉 🚀 ✨ 🌈', text: [ 'Faces: 😀 😃 😄 😁 😆 😅 😂', 'Objects: 🎉 🚀 ✨ 🌈 ⭐ 🔥 💎', 'Animals: 🐶 🐱 🐭 🐹 🐰 🦊 🐻', 'Food: 🍎 🍌 🍇 🍓 🥝 🍅 🥑', 'Symbols: ✓ ✗ ⚠ ♠ ♣ ♥ ♦', 'Math: ∑ ∏ ∫ ∞ ± × ÷ ≠ ≤ ≥' ].join('\n'), html: `

Emojis and Symbols Test 🎉

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: `

International Mix 🌍

English: Hello World!

Chinese: 你好世界!

Arabic: مرحبا بالعالم!

Japanese: こんにちは世界!

Russian: Привет мир!

Greek: Γεια σας κόσμε!

Mixed: Hello 世界 🌍 مرحبا こんにちは!

` }); const result = await smtpClient.sendMail(email); expect(result).toBeDefined(); expect(result.messageId).toBeDefined(); console.log('Successfully sent email with mixed international content'); await smtpClient.close(); }); tap.test('cleanup test SMTP server', async () => { if (testServer) { await stopTestServer(testServer); } }); export default tap.start();