Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

imap-client

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imap-client - npm Package Compare versions

Comparing version 0.8.1 to 0.9.0

4

package.json
{
"name": "imap-client",
"version": "0.8.1",
"version": "0.9.0",
"scripts": {

@@ -10,3 +10,3 @@ "pretest": "dir=$(pwd) && cd node_modules/browserbox/node_modules/tcp-socket/node_modules/node-forge/ && npm install && npm run minify && cd $dir",

"dependencies": {
"browserbox": "~0.5.2",
"browserbox": "~0.6.0",
"axe-logger": "~0.0.2"

@@ -13,0 +13,0 @@ },

@@ -494,6 +494,4 @@ (function(factory) {

ImapClient.prototype.selectMailbox = function(options, callback) {
if (this._client.selectedMailbox !== options.path) {
axe.debug(DEBUG_TAG, 'selecting mailbox ' + options.path);
this._client.selectMailbox(options.path, callback);
}
axe.debug(DEBUG_TAG, 'selecting mailbox ' + options.path);
this._client.selectMailbox(options.path, callback);
};

@@ -608,3 +606,4 @@

queryOptions = {
byUid: true
byUid: true,
precheck: self._ensurePath(options.path, client)
};

@@ -631,28 +630,13 @@

axe.debug(DEBUG_TAG, 'searching in ' + options.path + ' for ' + query);
if (client.selectedMailbox !== options.path) {
client.selectMailbox(options.path, onMailboxSelected);
} else {
onMailboxSelected();
}
function onMailboxSelected(error) {
axe.debug(DEBUG_TAG, 'searching in ' + options.path + ' for ' + Object.keys(query).join(','));
client.search(query, queryOptions, function(error, uids) {
if (error) {
axe.error(DEBUG_TAG, 'error selecting mailbox' + options.path + ' : ' + error + '\n' + error.stack);
callback(error);
return;
axe.error(DEBUG_TAG, 'error searching ' + options.path + ': ' + error + '\n' + error.stack);
return callback(error);
}
client.search(query, queryOptions, function(error, uids) {
if (error) {
axe.error(DEBUG_TAG, 'error searching mailbox: ' + error + '\n' + error.stack);
return callback(error);
}
axe.debug(DEBUG_TAG, 'searched in ' + options.path + ' for ' + Object.keys(query).join(',') + ': ' + uids);
axe.debug(DEBUG_TAG, 'searched in ' + options.path + ' for ' + query + ': ' + uids);
callback(null, uids);
});
}
callback(null, uids);
});
};

@@ -678,3 +662,4 @@

queryOptions = {
byUid: true
byUid: true,
precheck: self._ensurePath(options.path)
};

@@ -689,17 +674,4 @@

if (self._client.selectedMailbox !== options.path) {
self._client.selectMailbox(options.path, onMailboxSelected);
} else {
onMailboxSelected();
}
self._client.listMessages(interval, query, queryOptions, onList);
function onMailboxSelected(error) {
if (error) {
axe.error(DEBUG_TAG, 'error selecting mailbox' + options.path + ' : ' + error + '\n' + error.stack);
callback(error);
return;
}
self._client.listMessages(interval, query, queryOptions, onList);
}
// process what inbox returns into a usable form for our client

@@ -777,3 +749,4 @@ function onList(error, messages) {

queryOptions = {
byUid: true
byUid: true,
precheck: self._ensurePath(options.path)
},

@@ -814,19 +787,4 @@ interval = options.uid + ':' + options.uid,

if (self._client.selectedMailbox !== options.path) {
self._client.selectMailbox(options.path, onMailboxSelected);
} else {
onMailboxSelected();
}
self._client.listMessages(interval, query, queryOptions, onPartsReady);
// open the mailbox and retrieve the message
function onMailboxSelected(error) {
if (error) {
axe.error(DEBUG_TAG, 'error selecting mailbox' + options.path + ' : ' + error + '\n' + error.stack);
callback(error);
return;
}
self._client.listMessages(interval, query, queryOptions, onPartsReady);
}
function onPartsReady(error, messages) {

@@ -873,3 +831,4 @@ if (error) {

queryOptions = {
byUid: true
byUid: true,
precheck: self._ensurePath(options.path)
},

@@ -921,31 +880,18 @@ queryAdd,

if (self._client.selectedMailbox !== options.path) {
self._client.selectMailbox(options.path, onMailboxSelected);
} else {
onMailboxSelected();
if (add.length === 0) {
return onFlagsAdded();
}
function onMailboxSelected(error) {
if (error) {
axe.error(DEBUG_TAG, 'error selecting mailbox' + options.path + ' : ' + error + '\n' + error.stack);
onFlagsAdded(error);
}
self._client.setFlags(interval, queryAdd, queryOptions, onFlagsAdded);
if (add.length === 0) {
onFlagsAdded(error);
}
self._client.setFlags(interval, queryAdd, queryOptions, onFlagsAdded);
}
function onFlagsAdded(error) {
if (error || remove.length === 0) {
onFlagsRemoved(error);
done(error);
return;
}
self._client.setFlags(interval, queryRemove, queryOptions, onFlagsRemoved);
self._client.setFlags(interval, queryRemove, queryOptions, done);
}
function onFlagsRemoved(error) {
function done(error) {
if (error) {

@@ -973,3 +919,4 @@ axe.error(DEBUG_TAG, 'error updating flags for uid ' + options.uid + ' in folder ' + options.path + ' : ' + error + '\n' + error.stack);

queryOptions = {
byUid: true
byUid: true,
precheck: self._ensurePath(options.path)
};

@@ -984,23 +931,9 @@

if (self._client.selectedMailbox !== options.path) {
self._client.selectMailbox(options.path, onMailboxSelected);
} else {
onMailboxSelected();
}
function onMailboxSelected(error) {
self._client.moveMessages(interval, options.destination, queryOptions, function(error) {
if (error) {
axe.error(DEBUG_TAG, 'error selecting mailbox' + options.path + ' : ' + error + '\n' + error.stack);
callback(error);
return;
axe.error(DEBUG_TAG, 'error moving uid ' + options.uid + ' from ' + options.path + ' to ' + options.destination + ' : ' + error + '\n' + error.stack);
}
self._client.moveMessages(interval, options.destination, queryOptions, function(error) {
if (error) {
axe.error(DEBUG_TAG, 'error moving uid ' + options.uid + ' from ' + options.path + ' to ' + options.destination + ' : ' + error + '\n' + error.stack);
}
axe.debug(DEBUG_TAG, 'successfully moved uid ' + options.uid + ' from ' + options.path + ' to ' + options.destination);
callback(error);
});
}
axe.debug(DEBUG_TAG, 'successfully moved uid ' + options.uid + ' from ' + options.path + ' to ' + options.destination);
callback(error);
});
};

@@ -1043,3 +976,4 @@

queryOptions = {
byUid: true
byUid: true,
precheck: self._ensurePath(options.path)
};

@@ -1054,24 +988,35 @@

if (self._client.selectedMailbox !== options.path) {
self._client.selectMailbox(options.path, onMailboxSelected);
} else {
onMailboxSelected();
}
function onMailboxSelected(error) {
self._client.deleteMessages(interval, queryOptions, function(error) {
if (error) {
axe.error(DEBUG_TAG, 'error selecting mailbox' + options.path + ' : ' + error + '\n' + error.stack);
callback(error);
return;
axe.error(DEBUG_TAG, 'error deleting uid ' + options.uid + ' from ' + options.path + ' : ' + error + '\n' + error.stack);
}
self._client.deleteMessages(interval, queryOptions, function(error) {
if (error) {
axe.error(DEBUG_TAG, 'error deleting uid ' + options.uid + ' from ' + options.path + ' : ' + error + '\n' + error.stack);
}
axe.debug(DEBUG_TAG, 'successfully deleted uid ' + options.uid + ' from ' + options.path);
callback(error);
});
};
axe.debug(DEBUG_TAG, 'successfully deleted uid ' + options.uid + ' from ' + options.path);
callback(error);
});
}
//
// Helper methods
//
/**
* Makes sure that the respective instance of browserbox is in the correct mailbox to run the command
*
* @param {String} path The mailbox path
*/
ImapClient.prototype._ensurePath = function(path, client) {
var self = this;
client = client || self._client;
return function(ctx, next) {
if (client.selectedMailbox === path) {
return next();
}
axe.debug(DEBUG_TAG, 'selecting mailbox ' + path);
client.selectMailbox(path, {
ctx: ctx
}, next);
};
};

@@ -1078,0 +1023,0 @@

@@ -27,7 +27,7 @@ (function(factory) {

describe('ImapClient t-online integration tests', function() {
this.timeout(5000);
this.timeout(50000);
chai.config.includeStack = true;
// don't log in the tests
axe.removeAppender({});
axe.removeAppender(axe.defaultAppender);

@@ -40,3 +40,6 @@ var ic;

ic.login(done);
ic.onCert = function () {};
ic.onCert = function() {};
ic.onError = function(error) {
console.error(error);
};
});

@@ -43,0 +46,0 @@

@@ -9,3 +9,2 @@ 'use strict';

hoodiecrow = require('hoodiecrow'),
axe = require('axe-logger'),
loginOptions = {

@@ -21,5 +20,2 @@ port: 12345,

// don't log in the tests
axe.removeAppender(axe.defaultAppender);
describe('ImapClient local integration tests', function() {

@@ -31,46 +27,45 @@ var ic, imap;

imap = hoodiecrow({
storage: {
'INBOX': {
messages: [{
raw: 'Message-Id: <abcde>\r\nSubject: hello 1\r\n\r\nWorld 1!'
}, {
raw: 'Message-Id: <abcde>\r\nSubject: hello 2\r\n\r\nWorld 2!',
flags: ['\\Seen']
}, {
raw: 'Message-Id: <abcde>\r\nSubject: hello 3\r\n\r\nWorld 3!'
}, {
raw: 'MIME-Version: 1.0\r\nDate: Tue, 01 Oct 2013 07:08:55 GMT\r\nMessage-Id: <1380611335900.56da46df@Nodemailer>\r\nFrom: alice@example.com\r\nTo: bob@example.com\r\nSubject: Hello\r\nContent-Type: multipart/mixed;\r\n boundary="----Nodemailer-0.5.3-dev-?=_1-1380611336047"\r\n\r\n------Nodemailer-0.5.3-dev-?=_1-1380611336047\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\nHello world\r\n------Nodemailer-0.5.3-dev-?=_1-1380611336047\r\nContent-Type: text/plain; name="foo.txt"\r\nContent-Disposition: attachment; filename="foo.txt"\r\nContent-Transfer-Encoding: base64\r\n\r\nZm9vZm9vZm9vZm9vZm9v\r\n------Nodemailer-0.5.3-dev-?=_1-1380611336047\r\nContent-Type: text/plain; name="bar.txt"\r\nContent-Disposition: attachment; filename="bar.txt"\r\nContent-Transfer-Encoding: base64\r\n\r\nYmFyYmFyYmFyYmFyYmFy\r\n------Nodemailer-0.5.3-dev-?=_1-1380611336047--',
}, {
raw: 'Content-Type: multipart/encrypted; boundary="Apple-Mail=_CC38E51A-DB4D-420E-AD14-02653EB88B69"; protocol="application/pgp-encrypted";\r\nSubject: [whiteout] attachment only\r\nFrom: Felix Hammerl <felix.hammerl@gmail.com>\r\nDate: Thu, 16 Jan 2014 14:55:56 +0100\r\nContent-Transfer-Encoding: 7bit\r\nMessage-Id: <3ECDF9DC-895E-4475-B2A9-52AF1F117652@gmail.com>\r\nContent-Description: OpenPGP encrypted message\r\nTo: safewithme.testuser@gmail.com\r\n\r\nThis is an OpenPGP/MIME encrypted message (RFC 2440 and 3156)\r\n--Apple-Mail=_CC38E51A-DB4D-420E-AD14-02653EB88B69\r\nContent-Transfer-Encoding: 7bit\r\nContent-Type: application/pgp-encrypted\r\nContent-Description: PGP/MIME Versions Identification\r\n\r\nVersion: 1\r\n\r\n--Apple-Mail=_CC38E51A-DB4D-420E-AD14-02653EB88B69\r\nContent-Transfer-Encoding: 7bit\r\nContent-Disposition: inline;\r\n filename=encrypted.asc\r\nContent-Type: application/octet-stream;\r\n name=encrypted.asc\r\nContent-Description: OpenPGP encrypted message\r\n\r\ninsert pgp here.\r\n\r\n--Apple-Mail=_CC38E51A-DB4D-420E-AD14-02653EB88B69--',
}, {
raw: 'MIME-Version: 1.0\r\nDate: Tue, 01 Oct 2013 07:08:55 GMT\r\nMessage-Id: <1380611335900.56da46df@Nodemailer>\r\nFrom: alice@example.com\r\nTo: bob@example.com\r\nSubject: Hello\r\nContent-Type: multipart/mixed;\r\n boundary="----Nodemailer-0.5.3-dev-?=_1-1380611336047"\r\n\r\n------Nodemailer-0.5.3-dev-?=_1-1380611336047\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\nHello world\r\n------Nodemailer-0.5.3-dev-?=_1-1380611336047\r\nContent-Type: text/plain; name="foo.txt"\r\nContent-Disposition: attachment; filename="foo.txt"\r\nContent-Transfer-Encoding: base64\r\n\r\nZm9vZm9vZm9vZm9vZm9v\r\n------Nodemailer-0.5.3-dev-?=_1-1380611336047\r\nContent-Type: text/plain; name="bar.txt"\r\nContent-Disposition: attachment; filename="bar.txt"\r\nContent-Transfer-Encoding: base64\r\n\r\nYmFyYmFyYmFyYmFyYmFy\r\n------Nodemailer-0.5.3-dev-?=_1-1380611336047--',
}]
},
'': {
'separator': '/',
'folders': {
'[Gmail]': {
'flags': ['\\Noselect'],
'folders': {
'All Mail': {
'flags': '\\All'
},
'Drafts': {
'flags': '\\Drafts'
},
'Important': {
'flags': '\\Important'
},
'Sent Mail': {
'flags': '\\Sent'
},
'Spam': {
'flags': '\\Junk'
},
'Starred': {
'flags': '\\Flagged'
},
'Trash': {
'flags': '\\Trash'
}
storage: {
'INBOX': {
messages: [{
raw: 'Message-Id: <abcde>\r\nSubject: hello 1\r\n\r\nWorld 1!'
}, {
raw: 'Message-Id: <abcde>\r\nSubject: hello 2\r\n\r\nWorld 2!',
flags: ['\\Seen']
}, {
raw: 'Message-Id: <abcde>\r\nSubject: hello 3\r\n\r\nWorld 3!'
}, {
raw: 'MIME-Version: 1.0\r\nDate: Tue, 01 Oct 2013 07:08:55 GMT\r\nMessage-Id: <1380611335900.56da46df@Nodemailer>\r\nFrom: alice@example.com\r\nTo: bob@example.com\r\nSubject: Hello\r\nContent-Type: multipart/mixed;\r\n boundary="----Nodemailer-0.5.3-dev-?=_1-1380611336047"\r\n\r\n------Nodemailer-0.5.3-dev-?=_1-1380611336047\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\nHello world\r\n------Nodemailer-0.5.3-dev-?=_1-1380611336047\r\nContent-Type: text/plain; name="foo.txt"\r\nContent-Disposition: attachment; filename="foo.txt"\r\nContent-Transfer-Encoding: base64\r\n\r\nZm9vZm9vZm9vZm9vZm9v\r\n------Nodemailer-0.5.3-dev-?=_1-1380611336047\r\nContent-Type: text/plain; name="bar.txt"\r\nContent-Disposition: attachment; filename="bar.txt"\r\nContent-Transfer-Encoding: base64\r\n\r\nYmFyYmFyYmFyYmFyYmFy\r\n------Nodemailer-0.5.3-dev-?=_1-1380611336047--'
}, {
raw: 'Content-Type: multipart/encrypted; boundary="Apple-Mail=_CC38E51A-DB4D-420E-AD14-02653EB88B69"; protocol="application/pgp-encrypted";\r\nSubject: [whiteout] attachment only\r\nFrom: Felix Hammerl <felix.hammerl@gmail.com>\r\nDate: Thu, 16 Jan 2014 14:55:56 +0100\r\nContent-Transfer-Encoding: 7bit\r\nMessage-Id: <3ECDF9DC-895E-4475-B2A9-52AF1F117652@gmail.com>\r\nContent-Description: OpenPGP encrypted message\r\nTo: safewithme.testuser@gmail.com\r\n\r\nThis is an OpenPGP/MIME encrypted message (RFC 2440 and 3156)\r\n--Apple-Mail=_CC38E51A-DB4D-420E-AD14-02653EB88B69\r\nContent-Transfer-Encoding: 7bit\r\nContent-Type: application/pgp-encrypted\r\nContent-Description: PGP/MIME Versions Identification\r\n\r\nVersion: 1\r\n\r\n--Apple-Mail=_CC38E51A-DB4D-420E-AD14-02653EB88B69\r\nContent-Transfer-Encoding: 7bit\r\nContent-Disposition: inline;\r\n filename=encrypted.asc\r\nContent-Type: application/octet-stream;\r\n name=encrypted.asc\r\nContent-Description: OpenPGP encrypted message\r\n\r\ninsert pgp here.\r\n\r\n--Apple-Mail=_CC38E51A-DB4D-420E-AD14-02653EB88B69--',
}, {
raw: 'MIME-Version: 1.0\r\nDate: Tue, 01 Oct 2013 07:08:55 GMT\r\nMessage-Id: <1380611335900.56da46df@Nodemailer>\r\nFrom: alice@example.com\r\nTo: bob@example.com\r\nSubject: Hello\r\nContent-Type: multipart/mixed;\r\n boundary="----Nodemailer-0.5.3-dev-?=_1-1380611336047"\r\n\r\n------Nodemailer-0.5.3-dev-?=_1-1380611336047\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\nHello world\r\n------Nodemailer-0.5.3-dev-?=_1-1380611336047\r\nContent-Type: text/plain; name="foo.txt"\r\nContent-Disposition: attachment; filename="foo.txt"\r\nContent-Transfer-Encoding: base64\r\n\r\nZm9vZm9vZm9vZm9vZm9v\r\n------Nodemailer-0.5.3-dev-?=_1-1380611336047\r\nContent-Type: text/plain; name="bar.txt"\r\nContent-Disposition: attachment; filename="bar.txt"\r\nContent-Transfer-Encoding: base64\r\n\r\nYmFyYmFyYmFyYmFyYmFy\r\n------Nodemailer-0.5.3-dev-?=_1-1380611336047--'
}]
},
'': {
'separator': '/',
'folders': {
'[Gmail]': {
'flags': ['\\Noselect'],
'folders': {
'All Mail': {
'flags': '\\All'
},
'Drafts': {
'flags': '\\Drafts'
},
'Important': {
'flags': '\\Important'
},
'Sent Mail': {
'flags': '\\Sent'
},
'Spam': {
'flags': '\\Junk'
},
'Starred': {
'flags': '\\Flagged'
},
'Trash': {
'flags': '\\Trash'
}

@@ -81,4 +76,6 @@ }

}
}),
imap.listen(loginOptions.port);
}
});
imap.listen(loginOptions.port);
});

@@ -100,17 +97,2 @@

it('should throw', function(done) {
var ic = new ImapClient(loginOptions);
ic.onError = function(err) {
expect(err.message).to.equal('Sync handler not set');
ic.logout(done);
};
ic.login(function() {
ic.listMessages({
path: 'INBOX',
firstUid: 1,
lastUid: 3
}, function() {});
});
});
it('should notify about new messages', function(done) {

@@ -313,17 +295,25 @@ var invocations = 0; // counts the message updates

ic.moveMessage({
ic.listMessages({
path: 'INBOX',
uid: 3,
destination: destination
}, function(error) {
firstUid: 1
}, function(error, messages) {
expect(error).to.not.exist;
expect(messages).to.not.be.empty;
ic.listMessages({
path: destination,
firstUid: 1
}, function(error, messages) {
ic.moveMessage({
path: 'INBOX',
uid: messages[0].uid,
destination: destination
}, function(error) {
expect(error).to.not.exist;
expect(messages).to.not.be.empty;
done();
ic.listMessages({
path: destination,
firstUid: 1
}, function(error, messages) {
expect(error).to.not.exist;
expect(messages).to.not.be.empty;
done();
});
});

@@ -361,3 +351,3 @@ });

// in the background and check back after a 1 s delay
setTimeout(function () {
setTimeout(function() {
expect(ic._listenerLoggedIn).to.be.false;

@@ -364,0 +354,0 @@ done();

@@ -208,8 +208,5 @@ (function(factory) {

it('should search answered', function(done) {
bboxMock.selectMailbox.withArgs('foobar').yieldsAsync();
bboxMock.search.withArgs({
all: true,
answered: true
}, {
byUid: true
}).yieldsAsync(null, [1, 3, 5]);

@@ -228,8 +225,5 @@

it('should search unanswered', function(done) {
bboxMock.selectMailbox.withArgs('foobar').yieldsAsync();
bboxMock.search.withArgs({
all: true,
unanswered: true
}, {
byUid: true
}).yieldsAsync(null, [1, 3, 5]);

@@ -248,8 +242,5 @@

it('should search read', function(done) {
bboxMock.selectMailbox.withArgs('foobar').yieldsAsync();
bboxMock.search.withArgs({
all: true,
seen: true
}, {
byUid: true
}).yieldsAsync(null, [1, 3, 5]);

@@ -268,8 +259,5 @@

it('should search unread', function(done) {
bboxMock.selectMailbox.withArgs('foobar').yieldsAsync();
bboxMock.search.withArgs({
all: true,
unseen: true
}, {
byUid: true
}).yieldsAsync(null, [1, 3, 5]);

@@ -350,6 +338,3 @@

}];
bboxMock.selectMailbox.withArgs('foobar').yieldsAsync();
bboxMock.listMessages.withArgs('1:2', ['uid', 'bodystructure', 'flags', 'envelope', 'body.peek[header.fields (references)]'], {
byUid: true
}).yieldsAsync(null, listing);
bboxMock.listMessages.withArgs('1:2', ['uid', 'bodystructure', 'flags', 'envelope', 'body.peek[header.fields (references)]']).yieldsAsync(null, listing);

@@ -362,3 +347,2 @@ imap.listMessages({

expect(error).to.not.exist;
expect(bboxMock.selectMailbox.calledOnce).to.be.true;
expect(bboxMock.listMessages.calledOnce).to.be.true;

@@ -398,17 +382,3 @@

it('should not list messages by uid due to select mailbox error', function(done) {
bboxMock.selectMailbox.yields({});
imap.listMessages({
path: 'foobar',
firstUid: 1,
lastUid: 2
}, function(error) {
expect(error).to.exist;
done();
});
});
it('should not list messages by uid due to list error', function(done) {
bboxMock.selectMailbox.yields();
bboxMock.listMessages.yields({});

@@ -436,6 +406,3 @@

it('should get the plain text body', function(done) {
bboxMock.selectMailbox.withArgs('foobar').yieldsAsync();
bboxMock.listMessages.withArgs('123:123', ['body.peek[1.mime]', 'body.peek[1]', 'body.peek[2.mime]', 'body.peek[2]'], {
byUid: true
}).yieldsAsync(null, [{
bboxMock.listMessages.withArgs('123:123', ['body.peek[1.mime]', 'body.peek[1]', 'body.peek[2.mime]', 'body.peek[2]']).yieldsAsync(null, [{
'body[1.mime]': 'qwe',

@@ -480,3 +447,2 @@ 'body[1]': 'asd',

expect(bboxMock.selectMailbox.called).to.be.false;
expect(bboxMock.listMessages.called).to.be.false;

@@ -489,3 +455,2 @@

it('should fail when list fails', function(done) {
bboxMock.selectMailbox.withArgs('foobar').yieldsAsync();
bboxMock.listMessages.yieldsAsync({});

@@ -507,19 +472,2 @@

it('should fail when select mailbox fails', function(done) {
bboxMock.selectMailbox.withArgs('foobar').yieldsAsync({});
imap.getBodyParts({
path: 'foobar',
uid: 123,
bodyParts: [{
partNumber: '1'
}, {
partNumber: '2'
}]
}, function(error) {
expect(error).to.exist;
done();
});
});
it('should not work when not logged in', function(done) {

@@ -539,7 +487,4 @@ imap._loggedIn = false;

it('should update flags', function(done) {
bboxMock.selectMailbox.withArgs('INBOX').yields();
bboxMock.setFlags.withArgs('123:123', {
add: ['\\Flagged', '\\Answered']
}, {
byUid: true
}).yields(null, [{

@@ -550,4 +495,2 @@ flags: ['\\Flagged', '\\Answered']

remove: ['\\Seen']
}, {
byUid: true
}).yields(null, [{

@@ -566,3 +509,2 @@ flags: ['\\Flagged', '\\Answered']

expect(bboxMock.selectMailbox.calledOnce).to.be.true;
expect(bboxMock.setFlags.calledTwice).to.be.true;

@@ -575,7 +517,4 @@

it('should update flags and skip remove', function(done) {
bboxMock.selectMailbox.withArgs('INBOX').yields();
bboxMock.setFlags.withArgs('123:123', {
add: ['\\Answered']
}, {
byUid: true
}).yields(null, [{

@@ -592,3 +531,2 @@ flags: ['\\Answered']

expect(bboxMock.selectMailbox.calledOnce).to.be.true;
expect(bboxMock.setFlags.calledOnce).to.be.true;

@@ -601,7 +539,4 @@

it('should update flags and skip add', function(done) {
bboxMock.selectMailbox.withArgs('INBOX').yields();
bboxMock.setFlags.withArgs('123:123', {
remove: ['\\Seen']
}, {
byUid: true
}).yields(null, [{

@@ -618,3 +553,2 @@ flags: []

expect(bboxMock.selectMailbox.calledOnce).to.be.true;
expect(bboxMock.setFlags.calledOnce).to.be.true;

@@ -627,3 +561,2 @@

it('should fail due to set flags error', function(done) {
bboxMock.selectMailbox.yieldsAsync();
bboxMock.setFlags.yieldsAsync({});

@@ -643,17 +576,2 @@

it('should fail due to select mailbox error', function(done) {
bboxMock.selectMailbox.yieldsAsync({});
imap.updateFlags({
path: 'INBOX',
uid: 123,
unread: false,
answered: true
}, function(error) {
expect(error).to.exist;
done();
});
});
it('should not update flags when not logged in', function() {

@@ -669,6 +587,3 @@ imap._loggedIn = false;

it('should work', function(done) {
bboxMock.selectMailbox.withArgs('INBOX').yields();
bboxMock.moveMessages.withArgs('123:123', 'asdasd', {
byUid: true
}).yields();
bboxMock.moveMessages.withArgs('123:123', 'asdasd').yields();

@@ -681,3 +596,2 @@ imap.moveMessage({

expect(error).to.not.exist;
expect(bboxMock.selectMailbox.calledOnce).to.be.true;
expect(bboxMock.moveMessages.calledOnce).to.be.true;

@@ -690,3 +604,2 @@

it('should fail due to move error', function(done) {
bboxMock.selectMailbox.yields();
bboxMock.moveMessages.yields({});

@@ -705,16 +618,2 @@

it('should fail due to select mailbox error', function(done) {
bboxMock.selectMailbox.yieldsAsync({});
imap.moveMessage({
path: 'INBOX',
uid: 123,
destination: 'asdasd'
}, function(error) {
expect(error).to.exist;
done();
});
});
it('should fail due to not logged in', function() {

@@ -764,6 +663,3 @@ imap._loggedIn = false;

it('should work', function(done) {
bboxMock.selectMailbox.withArgs('INBOX').yields();
bboxMock.deleteMessages.withArgs('123:123', {
byUid: true
}).yields(null);
bboxMock.deleteMessages.withArgs('123:123').yields(null);

@@ -775,3 +671,2 @@ imap.deleteMessage({

expect(error).to.not.exist;
expect(bboxMock.selectMailbox.calledOnce).to.be.true;
expect(bboxMock.deleteMessages.calledOnce).to.be.true;

@@ -785,3 +680,2 @@

it('should not fail due to delete error', function(done) {
bboxMock.selectMailbox.yields();
bboxMock.deleteMessages.yields({});

@@ -798,14 +692,2 @@

it('should fail due to select mailbox error', function(done) {
bboxMock.selectMailbox.yieldsAsync({});
imap.deleteMessage({
path: 'INBOX',
uid: 123,
}, function(error) {
expect(error).to.exist;
done();
});
});
it('should not fail due to not logged in', function() {

@@ -830,2 +712,3 @@ imap._loggedIn = false;

expect(bboxMock.connect.calledOnce).to.be.true;
expect(bboxMock.selectMailbox.calledOnce).to.be.true;
done();

@@ -837,4 +720,3 @@ });

it('should return an error when inbox could not be opened', function(done) {
bboxMock.selectMailbox.withArgs('INBOX').yields({});
bboxMock.selectMailbox.withArgs('INBOX').yields(new Error());
imap.listenForChanges({

@@ -844,2 +726,3 @@ path: 'INBOX'

expect(err).to.exist;
expect(bboxMock.selectMailbox.calledOnce).to.be.true;
done();

@@ -864,3 +747,25 @@ });

});
describe('#_ensurePath', function() {
var ctx = {};
it('should switch mailboxes', function(done) {
bboxMock.selectMailbox.withArgs('qweasdzxc', {ctx: ctx}).yields();
imap._ensurePath('qweasdzxc')(ctx, function(err) {
expect(err).to.not.exist;
expect(bboxMock.selectMailbox.calledOnce).to.be.true;
done();
});
});
it('should error during switching mailboxes', function(done) {
bboxMock.selectMailbox.withArgs('qweasdzxc', {ctx: ctx}).yields(new Error());
imap._ensurePath('qweasdzxc')(ctx, function(err) {
expect(err).to.exist;
expect(bboxMock.selectMailbox.calledOnce).to.be.true;
done();
});
});
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc