summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2021-06-23 19:09:03 +0200
committerDaniel Weipert <code@drogueronin.de>2021-06-23 19:09:03 +0200
commit9863e78cc9e80661f03b4332754f9f1bd026b5fd (patch)
tree1f181360bbe4ac82bfe8ab7897a7a308c249b2ec /test
parent128a4891b790ce23aee6a7e3743a55ecf6a2ca61 (diff)
Refactors migration and enhances tests
Diffstat (limited to 'test')
-rw-r--r--test/test.js39
1 files changed, 26 insertions, 13 deletions
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));
+ }
})();