mirror of
https://github.com/moparisthebest/mail
synced 2024-11-25 18:32:20 -05:00
implement list folders in controller and dao
This commit is contained in:
parent
e8bf77d1ad
commit
898a934291
@ -52,6 +52,15 @@ define(function(require) {
|
||||
});
|
||||
});
|
||||
|
||||
} else if (cmd === 'listFolders') {
|
||||
// list folders in users mailbox
|
||||
self._emailDao.imapListFolders(function(err, folders) {
|
||||
callback({
|
||||
err: err,
|
||||
folders: folders
|
||||
});
|
||||
});
|
||||
|
||||
} else if (cmd === 'syncEmails') {
|
||||
// list emails from folder
|
||||
self._emailDao.syncFromCloud(args.folder, function(err) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
define(['jquery', 'backbone', 'js/view/login-view', 'js/view/compose-view',
|
||||
'js/view/folderlist-view', 'js/view/messagelist-view', 'js/view/read-view',
|
||||
'jquerymobile'
|
||||
'js/view/folderlist-view', 'js/view/messagelist-view', 'js/view/read-view',
|
||||
'jquerymobile'
|
||||
], function($, Backbone, LoginView, ComposeView, FolderListView, MessageListView, ReadView) {
|
||||
'use strict';
|
||||
|
||||
@ -42,6 +42,7 @@ define(['jquery', 'backbone', 'js/view/login-view', 'js/view/compose-view',
|
||||
account: userId
|
||||
});
|
||||
this.changePage(folderListView);
|
||||
folderListView.listFolder();
|
||||
},
|
||||
|
||||
messagelist: function(userId, folder) {
|
||||
|
@ -122,9 +122,9 @@ define(function(require) {
|
||||
* List the folders in the user's IMAP mailbox.
|
||||
*/
|
||||
EmailDAO.prototype.imapListFolders = function(callback) {
|
||||
callback({
|
||||
errMsg: 'Not yet implemented!'
|
||||
});
|
||||
var self = this;
|
||||
|
||||
self._imapClient.listFolders(callback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -20,6 +20,30 @@ define(['jquery', 'underscore', 'backbone', 'js/app-config'], function($, _, Bac
|
||||
});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
listFolder: function() {
|
||||
// var page = $(this.el);
|
||||
|
||||
// show loading msg during init
|
||||
$.mobile.loading('show', {
|
||||
text: 'Fetching folders...',
|
||||
textVisible: true,
|
||||
theme: 'c'
|
||||
});
|
||||
|
||||
// post message to main window
|
||||
app.util.postMessage('listFolders', {}, function(resArgs) {
|
||||
var err = resArgs.err;
|
||||
|
||||
$.mobile.loading('hide');
|
||||
if (err) {
|
||||
window.alert(err.errMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(resArgs);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -78,6 +78,20 @@ define(function(require) {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('listFolders', function() {
|
||||
it('should work', function(done) {
|
||||
controller._emailDao.imapListFolders.yields(null, ['inbox', 'sent']);
|
||||
controller.execute('listFolders', {
|
||||
password: appControllerTest.passphrase
|
||||
}, function(resArgs) {
|
||||
expect(resArgs.err).to.not.exist;
|
||||
expect(resArgs.folders[1]).to.equal('sent');
|
||||
expect(controller._emailDao.imapListFolders.called).to.be.true;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -108,20 +108,33 @@ define(function(require) {
|
||||
});
|
||||
});
|
||||
|
||||
it('send an email via STMP bad case', function(done) {
|
||||
emailDao.smtpSend({}, function(err) {
|
||||
expect(smtpClientStub.send.called).to.be.false;
|
||||
expect(err).to.exist;
|
||||
done();
|
||||
describe('send email via SMTP', function() {
|
||||
it('should fail due to back input', function(done) {
|
||||
emailDao.smtpSend({}, function(err) {
|
||||
expect(smtpClientStub.send.called).to.be.false;
|
||||
expect(err).to.exist;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('send an email via STMP good case', function(done) {
|
||||
smtpClientStub.send.yields();
|
||||
emailDao.smtpSend(dummyMail, function(err) {
|
||||
expect(smtpClientStub.send.calledOnce).to.be.true;
|
||||
expect(err).to.not.exist;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('send an email via STMP good case', function(done) {
|
||||
smtpClientStub.send.yields();
|
||||
emailDao.smtpSend(dummyMail, function(err) {
|
||||
expect(smtpClientStub.send.calledOnce).to.be.true;
|
||||
expect(err).to.not.exist;
|
||||
done();
|
||||
describe('list IMAP folders', function() {
|
||||
it('should work', function(done) {
|
||||
imapClientStub.listFolders.yields();
|
||||
emailDao.imapListFolders(function(err) {
|
||||
expect(imapClientStub.listFolders.calledOnce).to.be.true;
|
||||
expect(err).to.not.exist;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user