fix(imap client): harden IMAP client message processing and modernize test tooling
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
||||
import { tapNodeTools } from '@push.rocks/tapbundle/node';
|
||||
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,
|
||||
@@ -17,13 +23,11 @@ tap.test('smartimap', async () => {
|
||||
filter: { seen: true, to: await tapNodeTools.getEnvVarOnDemand('IMAP_USER'), },
|
||||
});
|
||||
|
||||
await testSmartImap.connect();
|
||||
|
||||
testSmartImap.on('message', (message: smartimap.SmartImapMessage) => {
|
||||
console.log(message.subject);
|
||||
});
|
||||
|
||||
testSmartImap.on('error', (error) => {
|
||||
testSmartImap.on('error', (error: Error) => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
@@ -34,6 +38,9 @@ tap.test('smartimap', async () => {
|
||||
testSmartImap.on('disconnected', () => {
|
||||
console.log('Disconnected');
|
||||
});
|
||||
|
||||
await testSmartImap.connect();
|
||||
await testSmartImap.disconnect();
|
||||
});
|
||||
|
||||
tap.start();
|
||||
export default tap.start();
|
||||
@@ -1,5 +1,4 @@
|
||||
import { tap, expect, expectAsync } from '@push.rocks/tapbundle';
|
||||
import { jestExpect } from '@push.rocks/tapbundle/node';
|
||||
import { tap } from '@git.zone/tstest/tapbundle';
|
||||
|
||||
import { ImapServer } from '../ts/classes.imapserver.js';
|
||||
|
||||
@@ -26,4 +25,4 @@ tap.test('imapserver', async () => {
|
||||
// imapServer.start(143);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
export default tap.start();
|
||||
Reference in New Issue
Block a user