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;