cleanup and test email dao integration of imap-client

This commit is contained in:
Tankred Hase 2013-09-20 18:44:14 +02:00
parent a3849af57f
commit fbaa43aff6
3 changed files with 25 additions and 6 deletions

View File

@ -6,9 +6,8 @@ define(function(require) {
moment = require('moment'),
emailDao;
var MailListCtrl = function($scope, $routeParams) {
$scope.folder = $routeParams.folder || 'INBOX';
$scope.messageId = $routeParams.messageId;
var MailListCtrl = function($scope) {
$scope.folder = 'INBOX';
emailDao = appController._emailDao;
$scope.select = function(email) {

View File

@ -284,7 +284,16 @@ define(function(require) {
EmailDAO.prototype.imapListFolders = function(callback) {
var self = this;
self._imapClient.listFolders(callback);
self._imapClient.listAllFolders(callback);
};
/**
* Get the number of unread message for a folder
*/
EmailDAO.prototype.unreadMessages = function(path, callback) {
var self = this;
self._imapClient.unreadMessages(path, callback);
};
/**

View File

@ -241,9 +241,20 @@ define(function(require) {
describe('IMAP: list folders', function() {
it('should work', function(done) {
imapClientStub.listFolders.yields();
imapClientStub.listAllFolders.yields();
emailDao.imapListFolders(function(err) {
expect(imapClientStub.listFolders.calledOnce).to.be.true;
expect(imapClientStub.listAllFolders.calledOnce).to.be.true;
expect(err).to.not.exist;
done();
});
});
});
describe('IMAP: get unread messages for folder', function() {
it('should work', function(done) {
imapClientStub.unreadMessages.yields();
emailDao.unreadMessages(function(err) {
expect(imapClientStub.unreadMessages.calledOnce).to.be.true;
expect(err).to.not.exist;
done();
});