From 8e88ae7f990135ee18b71da0471eed94a9498e13 Mon Sep 17 00:00:00 2001 From: Felix Hammerl Date: Mon, 2 Dec 2013 19:48:35 +0100 Subject: [PATCH] add move --- src/js/dao/email-dao-2.js | 8 ++++++++ test/new-unit/email-dao-2-test.js | 32 +++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/js/dao/email-dao-2.js b/src/js/dao/email-dao-2.js index cf08f6e..650ba78 100644 --- a/src/js/dao/email-dao-2.js +++ b/src/js/dao/email-dao-2.js @@ -500,6 +500,14 @@ define(function(require) { }, callback); }; + EmailDAO.prototype.move = function(options, callback) { + this._imapClient.moveMessage({ + path: options.folder, + uid: options.uid, + destination: options.destination + }, callback); + }; + EmailDAO.prototype.sendEncrypted = function(options, callback) { var self = this, email = options.email; diff --git a/test/new-unit/email-dao-2-test.js b/test/new-unit/email-dao-2-test.js index 20f20e7..2e4fedf 100644 --- a/test/new-unit/email-dao-2-test.js +++ b/test/new-unit/email-dao-2-test.js @@ -1139,7 +1139,11 @@ define(function(require) { describe('markAsRead', function() { it('should work', function(done) { - imapClientStub.updateFlags.yields(); + imapClientStub.updateFlags.withArgs({ + path: 'asdf', + uid: 1, + unread: false + }).yields(); dao.markRead({ folder: 'asdf', @@ -1154,7 +1158,11 @@ define(function(require) { describe('markAsAnswered', function() { it('should work', function(done) { - imapClientStub.updateFlags.yields(); + imapClientStub.updateFlags.withArgs({ + path: 'asdf', + uid: 1, + answered: true + }).yields(); dao.markAnswered({ folder: 'asdf', @@ -1167,6 +1175,26 @@ define(function(require) { }); }); + describe('move', function() { + it('should work', function(done) { + imapClientStub.moveMessage.withArgs({ + path: 'asdf', + uid: 1, + destination: 'asdasd' + }).yields(); + + dao.move({ + folder: 'asdf', + uid: 1, + destination: 'asdasd' + }, function(err) { + expect(imapClientStub.moveMessage.calledOnce).to.be.true; + expect(err).to.not.exist; + done(); + }); + }); + }); + describe('sendPlaintext', function() { it('should work', function(done) { smtpClientStub.send.withArgs(dummyEncryptedMail).yields();