1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-22 08:52:15 -05:00

[WO-745] Adapt changes in imap-client v0.8.0

This commit is contained in:
Felix Hammerl 2014-12-01 10:45:30 +01:00
parent 9bee0f3def
commit a177503bdd
4 changed files with 27 additions and 22 deletions

View File

@ -60,7 +60,7 @@
"grunt-string-replace": "~1.0.0",
"grunt-svgmin": "~1.0.0",
"grunt-svgstore": "~0.3.4",
"imap-client": "~0.7.0",
"imap-client": "~0.8.0",
"jquery": "~2.1.1",
"mailreader": "~0.4.0",
"mocha": "^1.21.4",
@ -72,4 +72,4 @@
"time-grunt": "^1.0.0",
"wo-smtpclient": "~0.5.0"
}
}
}

View File

@ -1218,20 +1218,19 @@ Email.prototype.onConnect = function(options, callback) {
* It will discard the imap client and pgp mailer
*/
Email.prototype.onDisconnect = function(callback) {
var self = this;
// logout of imap-client
self._imapClient.logout(function() {
// ignore error, because it's not problem if logout fails
if (callback) {
callback();
}
});
// ignore error, because it's not problem if logout fails
this._imapClient.stopListeningForChanges(function() {});
this._imapClient.logout(function() {});
// discard clients
self._account.online = false;
self._imapClient = undefined;
self._pgpMailer = undefined;
this._account.online = false;
this._imapClient = undefined;
this._pgpMailer = undefined;
if (callback) {
callback();
}
};
/**

View File

@ -312,10 +312,11 @@ describe('Email DAO integration tests', function() {
mailreader.startWorker.restore();
accountService.onConnect.restore();
imapClient._client.close();
imapClient._listeningClient.close();
userStorage.clear(done);
imapClient.stopListeningForChanges(function() {
imapClient.logout(function() {
userStorage.clear(done);
});
});
});
describe('IMAP Integration Tests', function() {

View File

@ -1875,13 +1875,18 @@ describe('Email DAO unit tests', function() {
describe('#onDisconnect', function() {
it('should discard imapClient and pgpMailer', function(done) {
imapClientStub.logout.yieldsAsync();
imapClientStub.stopListeningForChanges.yields();
imapClientStub.logout.yields();
dao.onDisconnect(done);
dao.onDisconnect(function() {
expect(imapClientStub.stopListeningForChanges.calledOnce).to.be.true;
expect(imapClientStub.logout.calledOnce).to.be.true;
expect(dao._account.online).to.be.false;
expect(dao._imapClient).to.not.exist;
expect(dao._pgpMailer).to.not.exist;
done();
});
expect(dao._account.online).to.be.false;
expect(dao._imapClient).to.not.exist;
expect(dao._pgpMailer).to.not.exist;
});
});