add login and destroy

This commit is contained in:
Felix Hammerl 2013-11-28 11:46:08 +01:00
parent 1f89219353
commit 12860f6146
2 changed files with 57 additions and 15 deletions

View File

@ -117,24 +117,25 @@ define(function(require) {
// // IMAP Apis
// //
EmailDAO.prototype.login = function(callback) {
var self = this;
// login IMAP client if existent
self._imapClient.login(callback);
};
/**
* Cleanup by logging the user off.
*/
EmailDAO.prototype.destroy = function(callback) {
var self = this;
self._imapClient.logout(callback);
};
// /**
// * Login the imap client
// */
// EmailDAO.prototype.imapLogin = function(callback) {
// var self = this;
// // login IMAP client if existent
// self._imapClient.login(callback);
// };
// /**
// * Cleanup by logging the user off.
// */
// EmailDAO.prototype.destroy = function(callback) {
// var self = this;
// self._imapClient.logout(callback);
// };
// /**
// * List the folders in the user's IMAP mailbox.

View File

@ -217,5 +217,46 @@ define(function(require) {
});
});
});
describe('login', function() {
it('should work', function(done) {
imapClientStub.login.yields();
dao.login(function(err) {
expect(err).to.not.exist;
done();
});
});
it('should fail due to error in imap login', function(done) {
imapClientStub.login.yields({});
dao.login(function(err) {
expect(err).to.exist;
done();
});
});
});
describe('destroy', function() {
it('should work', function(done) {
imapClientStub.logout.yields();
dao.destroy(function(err) {
expect(err).to.not.exist;
done();
});
});
it('should fail due to error in imap login', function(done) {
imapClientStub.logout.yields({});
dao.destroy(function(err) {
expect(err).to.exist;
done();
});
});
});
});
});