1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-22 17:02:17 -05:00

listing messages in ui works, change app controller to use spaces instead of tabs

This commit is contained in:
Tankred Hase 2013-08-20 19:48:49 +02:00
parent 7776255784
commit feae2b0c2b
4 changed files with 239 additions and 184 deletions

View File

@ -63,16 +63,20 @@ define(function(require) {
});
} else if (cmd === 'syncEmails') {
// list emails from folder
self._emailDao.syncFromCloud(args.folder, function(err) {
// self._emailDao.syncFromCloud(args.folder, function(err) {
// callback({
// err: err
// });
// });
// Syncing to local storage is not yet supported for imap
callback({
err: err
});
err: 'Not yet implemented!'
});
} else if (cmd === 'listEmails') {
// list emails from folder
self._emailDao.listItems(args.folder, args.offset, args.num, function(err, emails) {
self._emailDao.imapListMessages(args, function(err, emails) {
callback({
err: err,
emails: emails

View File

@ -130,13 +130,25 @@ define(function(require) {
/**
* List messages from an imap folder. This will not yet fetch the email body.
* @param {String} options.folderName The name of the imap folder.
* @param {Number} offset The offset of items to fetch (0 is the last stored item)
* @param {Number} num The number of items to fetch (null means fetch all)
* @param {Number} options.offset The offset of items to fetch (0 is the last stored item)
* @param {Number} options.num The number of items to fetch (null means fetch all)
*/
EmailDAO.prototype.imapListMessages = function(options, callback) {
var self = this;
// validate options
if (!options.folder || typeof options.offset === 'undefined' || typeof options.num === 'undefined') {
callback({
errMsg: 'Not yet implemented!'
errMsg: 'Invalid options!'
});
return;
}
self._imapClient.listMessages({
path: options.folder,
offset: options.offset,
length: options.num
}, callback);
};
/**

View File

@ -59,8 +59,8 @@ define(function(require) {
}, function(resArgs) {
expect(resArgs.err).to.not.exist;
expect(resArgs.userId).to.equal(appControllerTest.user);
expect($.ajax.called).to.be.true;
expect(window.chrome.identity.getAuthToken.called).to.be.true;
expect($.ajax.calledOnce).to.be.true;
expect(window.chrome.identity.getAuthToken.calledOnce).to.be.true;
done();
});
});
@ -73,7 +73,7 @@ define(function(require) {
password: appControllerTest.passphrase
}, function(resArgs) {
expect(resArgs.err).to.not.exist;
expect(controller._emailDao.smtpSend.called).to.be.true;
expect(controller._emailDao.smtpSend.calledOnce).to.be.true;
done();
});
});
@ -87,7 +87,23 @@ define(function(require) {
}, function(resArgs) {
expect(resArgs.err).to.not.exist;
expect(resArgs.folders[1]).to.equal('sent');
expect(controller._emailDao.imapListFolders.called).to.be.true;
expect(controller._emailDao.imapListFolders.calledOnce).to.be.true;
done();
});
});
});
describe('listEmails', function() {
it('should work', function(done) {
controller._emailDao.imapListMessages.yields(null, []);
controller.execute('listEmails', {
folder: 'INBOX',
offset: 0,
num: 10
}, function(resArgs) {
expect(resArgs.err).to.not.exist;
expect(resArgs.emails).to.a('Array');
expect(controller._emailDao.imapListMessages.calledOnce).to.be.true;
done();
});
});

View File

@ -137,6 +137,29 @@ define(function(require) {
});
});
});
describe('list IMAP messages from folder', function() {
it('should fail due to bad options', function(done) {
emailDao.imapListMessages({}, function(err) {
expect(imapClientStub.listMessages.called).to.be.false;
expect(err).to.exist;
done();
});
});
it('should work', function(done) {
imapClientStub.listMessages.yields();
emailDao.imapListMessages({
folder: 'INBOX',
offset: 0,
num: 10
}, function(err) {
expect(imapClientStub.listMessages.calledOnce).to.be.true;
expect(err).to.not.exist;
done();
});
});
});
});
});