2026-05-01 16:59:04 +00:00
|
|
|
import { tap } from '@git.zone/tstest/tapbundle';
|
|
|
|
|
import { TapNodeTools } from '@git.zone/tstest/tapbundle_serverside';
|
2024-09-19 10:33:57 +02:00
|
|
|
import * as smartimap from '../ts/index.js';
|
|
|
|
|
|
2024-11-26 22:58:26 +01:00
|
|
|
let testSmartImap: smartimap.ImapClient;
|
2026-05-01 16:59:04 +00:00
|
|
|
const tapNodeTools = new TapNodeTools(tap);
|
2024-09-19 10:33:57 +02:00
|
|
|
|
|
|
|
|
tap.test('smartimap', async () => {
|
2026-05-01 16:59:04 +00:00
|
|
|
if (process.env.SMARTIMAP_RUN_INTEGRATION_TESTS !== 'true') {
|
|
|
|
|
console.log('Skipping IMAP integration test. Set SMARTIMAP_RUN_INTEGRATION_TESTS=true to run it.');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-26 22:58:26 +01:00
|
|
|
testSmartImap = new smartimap.ImapClient({
|
2024-09-19 10:33:57 +02:00
|
|
|
host: await tapNodeTools.getEnvVarOnDemand('IMAP_URL'),
|
|
|
|
|
port: 993,
|
|
|
|
|
secure: true,
|
|
|
|
|
auth: {
|
|
|
|
|
user: await tapNodeTools.getEnvVarOnDemand('IMAP_USER'),
|
|
|
|
|
pass: await tapNodeTools.getEnvVarOnDemand('IMAP_PASSWORD'),
|
|
|
|
|
},
|
2024-11-26 22:58:26 +01:00
|
|
|
mailbox: 'INBOX',
|
2024-09-19 12:59:14 +02:00
|
|
|
filter: { seen: true, to: await tapNodeTools.getEnvVarOnDemand('IMAP_USER'), },
|
2024-09-19 10:33:57 +02:00
|
|
|
});
|
|
|
|
|
|
2024-11-26 22:58:26 +01:00
|
|
|
testSmartImap.on('message', (message: smartimap.SmartImapMessage) => {
|
|
|
|
|
console.log(message.subject);
|
2024-09-19 10:33:57 +02:00
|
|
|
});
|
|
|
|
|
|
2026-05-01 16:59:04 +00:00
|
|
|
testSmartImap.on('error', (error: Error) => {
|
2024-09-19 10:33:57 +02:00
|
|
|
console.error(error);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testSmartImap.on('connected', () => {
|
|
|
|
|
console.log('Connected');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testSmartImap.on('disconnected', () => {
|
|
|
|
|
console.log('Disconnected');
|
|
|
|
|
});
|
2026-05-01 16:59:04 +00:00
|
|
|
|
|
|
|
|
await testSmartImap.connect();
|
|
|
|
|
await testSmartImap.disconnect();
|
2024-09-19 10:33:57 +02:00
|
|
|
});
|
|
|
|
|
|
2026-05-01 16:59:04 +00:00
|
|
|
export default tap.start();
|