summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2021-06-22 14:49:43 +0200
committerDaniel Weipert <code@drogueronin.de>2021-06-22 14:49:43 +0200
commit128a4891b790ce23aee6a7e3743a55ecf6a2ca61 (patch)
tree6d349ac096aef3f8e5a11242c4bf662990337119 /test
parentf6096a18016be63c719d2ce5a27d64363862b0fd (diff)
Working migrations with duplicate comparison
Diffstat (limited to 'test')
-rw-r--r--test/test.js82
1 files changed, 82 insertions, 0 deletions
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());
+})();