smartimap/test/test.imapserver.ts

30 lines
861 B
TypeScript

import { tap, expect, expectAsync } from '@push.rocks/tapbundle';
import { jestExpect } from '@push.rocks/tapbundle/node';
import { ImapServer } from '../ts/classes.imapserver.js';
tap.test('imapserver', async () => {
// Example usage
const imapServer = new ImapServer();
imapServer.addUser('testuser', 'password');
imapServer.createInbox('testuser', 'INBOX');
imapServer.createInbox('testuser', 'Sent');
// Add a sample message
const testUser = imapServer.users.get('testuser')!;
const inbox = testUser.inboxes.get('INBOX')!;
inbox.messages.push({
id: '1',
subject: 'Welcome',
sender: 'no-reply@example.com',
recipient: 'testuser@example.com',
date: new Date(),
body: 'Welcome to your new IMAP inbox!',
});
// Start the server on port 143 (commonly used for IMAP)
// imapServer.start(143);
});
tap.start();