From 128a4891b790ce23aee6a7e3743a55ecf6a2ca61 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 22 Jun 2021 14:49:43 +0200 Subject: Working migrations with duplicate comparison --- test/test.js | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 test/test.js (limited to 'test') diff --git a/test/test.js b/test/test.js new file mode 100644 index 0000000..dad4b9f --- /dev/null +++ b/test/test.js @@ -0,0 +1,82 @@ +const { ImapFlow } = require('imapflow'); + +const clientFrom = new ImapFlow({ + host: 'localhost', + port: 3143, + auth: { + user: 'from@example.org', + pass: 'password', + }, +}); + +const clientTo = new ImapFlow({ + host: 'localhost', + port: 31432, + auth: { + user: 'to@example.org', + pass: 'password', + }, +}); + +(async () => { + await clientFrom.connect(); + await clientTo.connect(); + + const fromMailboxes = [ + 'From Test Parent.From Test Child', + 'From Test Parent.From Test Child 2.From Test Child Inner', + ]; + const toMailboxes = [ + 'To Test Parent.To Test Child', + 'To Test Parent.To Test Child 2.To Test Child Inner', + ]; + for (const mailbox of fromMailboxes) { + try { + await clientFrom.mailboxDelete(mailbox); + } catch (e) {} + try { + await clientTo.mailboxDelete(mailbox); + } catch (e) {} + + try { + await clientFrom.mailboxCreate(mailbox); + } catch (e) {} + } + for (const mailbox of toMailboxes) { + try { + await clientTo.mailboxDelete(mailbox); + } catch (e) {} + + try { + await clientTo.mailboxCreate(mailbox); + } catch (e) {} + } + + await clientFrom.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', + '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', + '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', + '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()); +})(); -- cgit v1.2.3