From 9863e78cc9e80661f03b4332754f9f1bd026b5fd Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 23 Jun 2021 19:09:03 +0200 Subject: Refactors migration and enhances tests --- test/test.js | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'test') diff --git a/test/test.js b/test/test.js index dad4b9f..eab0ca0 100644 --- a/test/test.js +++ b/test/test.js @@ -1,6 +1,6 @@ const { ImapFlow } = require('imapflow'); -const clientFrom = new ImapFlow({ +const fromClient = new ImapFlow({ host: 'localhost', port: 3143, auth: { @@ -9,7 +9,7 @@ const clientFrom = new ImapFlow({ }, }); -const clientTo = new ImapFlow({ +const toClient = new ImapFlow({ host: 'localhost', port: 31432, auth: { @@ -19,12 +19,13 @@ const clientTo = new ImapFlow({ }); (async () => { - await clientFrom.connect(); - await clientTo.connect(); + await fromClient.connect(); + await toClient.connect(); const fromMailboxes = [ 'From Test Parent.From Test Child', 'From Test Parent.From Test Child 2.From Test Child Inner', + '10000 Mails', ]; const toMailboxes = [ 'To Test Parent.To Test Child', @@ -32,51 +33,63 @@ const clientTo = new ImapFlow({ ]; for (const mailbox of fromMailboxes) { try { - await clientFrom.mailboxDelete(mailbox); + await fromClient.mailboxDelete(mailbox); } catch (e) {} try { - await clientTo.mailboxDelete(mailbox); + await toClient.mailboxDelete(mailbox); } catch (e) {} try { - await clientFrom.mailboxCreate(mailbox); + await fromClient.mailboxCreate(mailbox); } catch (e) {} } for (const mailbox of toMailboxes) { try { - await clientTo.mailboxDelete(mailbox); + await toClient.mailboxDelete(mailbox); } catch (e) {} try { - await clientTo.mailboxCreate(mailbox); + await toClient.mailboxCreate(mailbox); } catch (e) {} } - await clientFrom.append('INBOX', + fromClient.append('INBOX', 'From: test@example.org\r\n' + 'To: from@example.org\r\n' + 'Subject: FROM INBOX MESSAGE SUBJECT\r\n' + '\r\n' + 'FROM INBOX MESSAGE BODY', [], new Date()); - await clientFrom.append('From Test Parent.From Test Child', + fromClient.append('From Test Parent.From Test Child', 'From: test@example.org\r\n' + 'To: from@example.org\r\n' + 'Subject: FROM TEST CHILD MESSAGE FLAGGED SUBJECT\r\n' + '\r\n' + 'FROM TEST CHILD MESSAGE FLAGGED BODY', ['\\FLAGGED'], new Date()); - await clientFrom.append('From Test Parent.From Test Child', + fromClient.append('From Test Parent.From Test Child', 'From: test@example.org\r\n' + 'To: from@example.org\r\n' + 'Subject: FROM TEST CHILD MESSAGE DRAFT SUBJECT\r\n' + '\r\n' + 'FROM TEST CHILD MESSAGE DRAFT BODY', ['\\DRAFT'], new Date()); - await clientFrom.append('From Test Parent.From Test Child 2.From Test Child Inner', + fromClient.append('From Test Parent.From Test Child 2.From Test Child Inner', 'From: test@example.org\r\n' + 'To: from@example.org\r\n' + 'Subject: FROM TEST CHILD 2 INNER MESSAGE SEEN SUBJECT\r\n' + '\r\n' + 'FROM TEST CHILD 2 INNER MESSAGE SEEN BODY', ['\\SEEN'], new Date()); + + for (let i = 0; i < 10000; i++) { + const flag = ['\\SEEN', '\\FLAGGED', ''][Math.floor(Math.random() * 3)]; + const now = new Date(); + + fromClient.append('10000 Mails', + 'From: test@example.org\r\n' + + 'To: from@example.org\r\n' + + `Subject: ${i}. MAIL\r\n` + + '\r\n' + + `MANY MAILS NUMBER ${i}`, [flag], new Date(now.getTime() - i * 60000)); + } })(); -- cgit v1.2.3