2024-09-19 08:33:57 +00:00
|
|
|
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
|
|
|
import { tapNodeTools } from '@push.rocks/tapbundle/node';
|
|
|
|
import * as smartimap from '../ts/index.js';
|
|
|
|
|
2024-11-26 21:58:26 +00:00
|
|
|
let testSmartImap: smartimap.ImapClient;
|
2024-09-19 08:33:57 +00:00
|
|
|
|
|
|
|
tap.test('smartimap', async () => {
|
2024-11-26 21:58:26 +00:00
|
|
|
testSmartImap = new smartimap.ImapClient({
|
2024-09-19 08:33:57 +00: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 21:58:26 +00:00
|
|
|
mailbox: 'INBOX',
|
2024-09-19 10:59:14 +00:00
|
|
|
filter: { seen: true, to: await tapNodeTools.getEnvVarOnDemand('IMAP_USER'), },
|
2024-09-19 08:33:57 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
await testSmartImap.connect();
|
|
|
|
|
2024-11-26 21:58:26 +00:00
|
|
|
testSmartImap.on('message', (message: smartimap.SmartImapMessage) => {
|
|
|
|
console.log(message.subject);
|
2024-09-19 08:33:57 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
testSmartImap.on('error', (error) => {
|
|
|
|
console.error(error);
|
|
|
|
});
|
|
|
|
|
|
|
|
testSmartImap.on('connected', () => {
|
|
|
|
console.log('Connected');
|
|
|
|
});
|
|
|
|
|
|
|
|
testSmartImap.on('disconnected', () => {
|
|
|
|
console.log('Disconnected');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.start();
|