mirror of
https://github.com/moparisthebest/mail
synced 2025-02-27 16:21:45 -05:00
fix bug in email dao init on first start
This commit is contained in:
parent
d08321d345
commit
0e6dfe2c26
@ -369,8 +369,7 @@ define(function(require) {
|
|||||||
self._emailDao.init({
|
self._emailDao.init({
|
||||||
account: account
|
account: account
|
||||||
}, function(err, keypair) {
|
}, function(err, keypair) {
|
||||||
// dont handle offline case this time
|
if (err) {
|
||||||
if (err && err.code !== 42) {
|
|
||||||
callback(err);
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,8 @@ define(function(require) {
|
|||||||
function initFolders() {
|
function initFolders() {
|
||||||
// try init folders from memory, since imap client not initiated yet
|
// try init folders from memory, since imap client not initiated yet
|
||||||
self._imapListFolders(function(err, folders) {
|
self._imapListFolders(function(err, folders) {
|
||||||
if (err) {
|
// dont handle offline case this time
|
||||||
|
if (err && err.code !== 42) {
|
||||||
callback(err);
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -266,8 +266,9 @@ define(function(require) {
|
|||||||
it('should fail due to error in emailDao.init', function(done) {
|
it('should fail due to error in emailDao.init', function(done) {
|
||||||
emailDaoStub.init.yields({});
|
emailDaoStub.init.yields({});
|
||||||
|
|
||||||
controller.init({}, function(err) {
|
controller.init({}, function(err, keypair) {
|
||||||
expect(err).to.exist;
|
expect(err).to.exist;
|
||||||
|
expect(keypair).to.not.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -284,22 +285,6 @@ define(function(require) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should pass email dao init when offline', function(done) {
|
|
||||||
emailDaoStub.init.yields({
|
|
||||||
code: 42
|
|
||||||
});
|
|
||||||
|
|
||||||
onConnectStub.yields();
|
|
||||||
outboxStub.init.returns();
|
|
||||||
|
|
||||||
controller.init({}, function(err) {
|
|
||||||
expect(err).to.not.exist;
|
|
||||||
expect(onConnectStub.calledOnce).to.be.true;
|
|
||||||
expect(outboxStub.init.calledOnce).to.be.true;
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should work and return a keypair', function(done) {
|
it('should work and return a keypair', function(done) {
|
||||||
emailDaoStub.init.yields(null, {});
|
emailDaoStub.init.yields(null, {});
|
||||||
|
|
||||||
|
@ -184,6 +184,35 @@ define(function(require) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not fail when offline', function(done) {
|
||||||
|
var listFolderStub;
|
||||||
|
|
||||||
|
// initKeychain
|
||||||
|
devicestorageStub.init.withArgs(emailAddress).yields();
|
||||||
|
keychainStub.getUserKeyPair.yields(null, mockKeyPair);
|
||||||
|
|
||||||
|
// initFolders
|
||||||
|
listFolderStub = sinon.stub(dao, '_imapListFolders');
|
||||||
|
listFolderStub.yields({code:42});
|
||||||
|
|
||||||
|
dao.init({
|
||||||
|
account: account
|
||||||
|
}, function(err, keyPair) {
|
||||||
|
expect(err).to.not.exist;
|
||||||
|
expect(dao._account.busy).to.be.false;
|
||||||
|
expect(dao._account.online).to.be.false;
|
||||||
|
expect(keyPair).to.equal(mockKeyPair);
|
||||||
|
|
||||||
|
expect(dao._account).to.equal(account);
|
||||||
|
expect(dao._account.folders).to.equal(undefined);
|
||||||
|
expect(devicestorageStub.init.calledOnce).to.be.true;
|
||||||
|
expect(keychainStub.getUserKeyPair.calledOnce).to.be.true;
|
||||||
|
expect(listFolderStub.calledOnce).to.be.true;
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should fail due to error while listing folders', function(done) {
|
it('should fail due to error while listing folders', function(done) {
|
||||||
var listFolderStub;
|
var listFolderStub;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user