fix(imap client): harden IMAP client message processing and modernize test tooling
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { tap } from '@git.zone/tstest/tapbundle';
|
||||
import { TapNodeTools } from '@git.zone/tstest/tapbundle_serverside';
|
||||
import * as smartimap from '../ts/index.js';
|
||||
|
||||
let testSmartImap: smartimap.ImapClient;
|
||||
const tapNodeTools = new TapNodeTools(tap);
|
||||
|
||||
tap.test('smartimap', async () => {
|
||||
if (process.env.SMARTIMAP_RUN_INTEGRATION_TESTS !== 'true') {
|
||||
console.log('Skipping IMAP integration test. Set SMARTIMAP_RUN_INTEGRATION_TESTS=true to run it.');
|
||||
return;
|
||||
}
|
||||
|
||||
testSmartImap = new smartimap.ImapClient({
|
||||
host: await tapNodeTools.getEnvVarOnDemand('IMAP_URL'),
|
||||
port: 993,
|
||||
secure: true,
|
||||
auth: {
|
||||
user: await tapNodeTools.getEnvVarOnDemand('IMAP_USER'),
|
||||
pass: await tapNodeTools.getEnvVarOnDemand('IMAP_PASSWORD'),
|
||||
},
|
||||
mailbox: 'INBOX',
|
||||
filter: { seen: true, to: await tapNodeTools.getEnvVarOnDemand('IMAP_USER'), },
|
||||
});
|
||||
|
||||
testSmartImap.on('message', (message: smartimap.SmartImapMessage) => {
|
||||
console.log(message.subject);
|
||||
});
|
||||
|
||||
testSmartImap.on('error', (error: Error) => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
testSmartImap.on('connected', () => {
|
||||
console.log('Connected');
|
||||
});
|
||||
|
||||
testSmartImap.on('disconnected', () => {
|
||||
console.log('Disconnected');
|
||||
});
|
||||
|
||||
await testSmartImap.connect();
|
||||
await testSmartImap.disconnect();
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
Reference in New Issue
Block a user