summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
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());
+})();