1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-22 17:02:17 -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",

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
this._imapClient.stopListeningForChanges(function() {});
this._imapClient.logout(function() {});
// discard clients
this._account.online = false;
this._imapClient = undefined;
this._pgpMailer = undefined;
if (callback) {
callback();
}
});
// discard clients
self._account.online = false;
self._imapClient = undefined;
self._pgpMailer = undefined;
};
/**

View File

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

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();
dao.onDisconnect(done);
imapClientStub.stopListeningForChanges.yields();
imapClientStub.logout.yields();
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();
});
});
});