2013-10-02 09:47:41 -04:00
|
|
|
define(function(require) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var appController = require('js/app-controller'),
|
|
|
|
expect = chai.expect;
|
|
|
|
|
|
|
|
var test = {
|
|
|
|
user: "whiteout.test@gmail.com",
|
|
|
|
passphrase: 'asdf'
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('Email DAO integration tests', function() {
|
|
|
|
this.timeout(5000);
|
|
|
|
|
|
|
|
var offset = 0,
|
|
|
|
num = 100,
|
|
|
|
emailDao;
|
|
|
|
|
|
|
|
beforeEach(function() {});
|
|
|
|
|
|
|
|
afterEach(function() {});
|
|
|
|
|
|
|
|
describe('login', function() {
|
2013-10-09 10:40:36 -04:00
|
|
|
this.timeout(20000);
|
|
|
|
|
2013-10-02 09:47:41 -04:00
|
|
|
it('should work', function(done) {
|
2013-10-09 10:40:36 -04:00
|
|
|
appController.start(function(err) {
|
2013-10-02 09:47:41 -04:00
|
|
|
expect(err).to.not.exist;
|
|
|
|
|
2013-10-09 10:40:36 -04:00
|
|
|
appController.fetchOAuthToken(test.passphrase, function(err) {
|
2013-10-02 09:47:41 -04:00
|
|
|
expect(err).to.not.exist;
|
2013-10-09 10:40:36 -04:00
|
|
|
emailDao = appController._emailDao;
|
|
|
|
|
|
|
|
emailDao.imapLogin(function(err) {
|
|
|
|
expect(err).to.not.exist;
|
|
|
|
done();
|
|
|
|
});
|
2013-10-02 09:47:41 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-10-10 13:15:16 -04:00
|
|
|
describe('List well known folders', function() {
|
|
|
|
it('should work', function(done) {
|
|
|
|
// clear folders from cache
|
|
|
|
emailDao._devicestorage.removeList('folders', function(err) {
|
|
|
|
expect(err).to.not.exist;
|
|
|
|
|
|
|
|
emailDao.imapListFolders(function(err, folders) {
|
|
|
|
expect(err).to.not.exist;
|
|
|
|
expect(folders.length).to.be.at.least(1);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-10-04 07:15:16 -04:00
|
|
|
describe('IMAP sync INBOX messages', function() {
|
2013-10-02 09:47:41 -04:00
|
|
|
it('should work', function(done) {
|
|
|
|
emailDao.imapSync({
|
|
|
|
folder: 'INBOX',
|
|
|
|
offset: -num,
|
|
|
|
num: offset
|
|
|
|
}, function(err) {
|
|
|
|
expect(err).to.not.exist;
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-10-04 07:15:16 -04:00
|
|
|
describe('IMAP list INBOX messages', function() {
|
2013-10-02 09:47:41 -04:00
|
|
|
it('should work', function(done) {
|
|
|
|
emailDao.listMessages({
|
|
|
|
folder: 'INBOX',
|
|
|
|
offset: offset,
|
|
|
|
num: num
|
|
|
|
}, function(err, emails) {
|
|
|
|
expect(err).to.not.exist;
|
|
|
|
expect(emails).to.exist;
|
|
|
|
expect(emails.length).to.be.at.least(1);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-10-04 07:15:16 -04:00
|
|
|
describe('IMAP sync SENT messages', function() {
|
|
|
|
it('should work', function(done) {
|
|
|
|
emailDao.imapSync({
|
|
|
|
folder: '[Gmail]/Gesendet',
|
|
|
|
offset: -num,
|
|
|
|
num: offset
|
|
|
|
}, function(err) {
|
|
|
|
expect(err).to.not.exist;
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('IMAP list SENT messages', function() {
|
|
|
|
it('should work', function(done) {
|
|
|
|
emailDao.listMessages({
|
|
|
|
folder: '[Gmail]/Gesendet',
|
|
|
|
offset: offset,
|
|
|
|
num: num
|
|
|
|
}, function(err, emails) {
|
|
|
|
expect(err).to.not.exist;
|
|
|
|
expect(emails).to.exist;
|
|
|
|
expect(emails.length).to.be.at.least(0);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-10-02 09:47:41 -04:00
|
|
|
});
|
|
|
|
});
|