From 78453fd4163943ea8854598820c67983b2cdd7b3 Mon Sep 17 00:00:00 2001 From: Felix Hammerl Date: Wed, 4 Dec 2013 12:06:27 +0100 Subject: [PATCH] reactivate push in email dao --- src/js/dao/email-dao.js | 12 ++++++------ test/new-unit/email-dao-test.js | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/js/dao/email-dao.js b/src/js/dao/email-dao.js index 396139f..66b6014 100644 --- a/src/js/dao/email-dao.js +++ b/src/js/dao/email-dao.js @@ -15,12 +15,12 @@ define(function(require) { self._crypto = crypto; self._devicestorage = devicestorage; - // // delegation-esque pattern to mitigate between node-style events and plain js - // self._imapClient.onIncomingMessage = function(message) { - // if (typeof self.onIncomingMessage === 'function') { - // self.onIncomingMessage(message); - // } - // }; + // delegation-esque pattern to mitigate between node-style events and plain js + self._imapClient.onIncomingMessage = function(message) { + if (typeof self.onIncomingMessage === 'function') { + self.onIncomingMessage(message); + } + }; }; // diff --git a/test/new-unit/email-dao-test.js b/test/new-unit/email-dao-test.js index 8290c37..96bc5d8 100644 --- a/test/new-unit/email-dao-test.js +++ b/test/new-unit/email-dao-test.js @@ -10,7 +10,7 @@ define(function(require) { expect = chai.expect; - describe('Email DAO 2 unit tests', function() { + describe('Email DAO unit tests', function() { var dao, keychainStub, imapClientStub, smtpClientStub, pgpStub, devicestorageStub; var emailAddress, passphrase, asymKeySize, mockkeyId, dummyEncryptedMail, @@ -105,6 +105,19 @@ define(function(require) { afterEach(function() {}); + describe('push', function() { + it('should work', function(done) { + var o = {}; + + dao.onIncomingMessage = function(obj) { + expect(obj).to.equal(o); + done(); + }; + + dao._imapClient.onIncomingMessage(o); + }); + }); + describe('init', function() { beforeEach(function() { delete dao._account;