diff --git a/.gitignore b/.gitignore index ad56970..bddb166 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,10 @@ node_modules/ npm-debug.log .DS_Store -*-browserified.js -test/new-unit/lib/ +test/lib/ .sass-cache dist/ +test/integration/src/ src/lib/*.js src/js/crypto/aes-cbc.js src/js/crypto/crypto-batch.js diff --git a/Gruntfile.js b/Gruntfile.js index 55ec737..f4eacd3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -68,7 +68,7 @@ module.exports = function(grunt) { }, clean: { - dist: ['dist', 'src/lib/*.js', 'test/new-unit/lib'] + dist: ['dist', 'src/lib/*.js', 'test/lib', 'test/integration/src'] }, sass: { dist: { @@ -147,8 +147,8 @@ module.exports = function(grunt) { expand: true, flatten: true, cwd: 'node_modules/', - src: ['mocha/mocha.css', 'mocha/mocha.js', 'chai/chai.js', 'sinon/pkg/sinon.js'], - dest: 'test/new-unit/lib/' + src: ['requirejs/require.js', 'mocha/mocha.css', 'mocha/mocha.js', 'chai/chai.js', 'sinon/pkg/sinon.js'], + dest: 'test/lib/' }, cryptoLib: { expand: true, @@ -191,6 +191,12 @@ module.exports = function(grunt) { cwd: 'src/', src: ['*.html', '*.js', '*.json'], dest: 'dist/' + }, + integration: { + expand: true, + cwd: 'src/', + src: ['**'], + dest: 'test/integration/src/' } } }); diff --git a/test/integration/background.js b/test/integration/background.js new file mode 100644 index 0000000..8bea8df --- /dev/null +++ b/test/integration/background.js @@ -0,0 +1,10 @@ +'use strict'; + +chrome.app.runtime.onLaunched.addListener(function() { + chrome.app.window.create('integration/index.html', { + 'bounds': { + 'width': 1024, + 'height': 768 + } + }); +}); \ No newline at end of file diff --git a/test/integration/email-dao-test.js b/test/integration/email-dao-test.js new file mode 100644 index 0000000..93c155c --- /dev/null +++ b/test/integration/email-dao-test.js @@ -0,0 +1,67 @@ +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() { + it('should work', function(done) { + appController.fetchOAuthToken(test.passphrase, function(err, userId) { + expect(err).to.not.exist; + expect(userId).to.exist; + emailDao = appController._emailDao; + + emailDao.imapLogin(function(err) { + expect(err).to.not.exist; + done(); + }); + }); + }); + }); + + describe('IMAP sync messages', function() { + it('should work', function(done) { + emailDao.imapSync({ + folder: 'INBOX', + offset: -num, + num: offset + }, function(err) { + expect(err).to.not.exist; + done(); + }); + }); + }); + + describe('IMAP sync messages', function() { + 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(); + }); + }); + }); + + }); +}); \ No newline at end of file diff --git a/test/integration/index.html b/test/integration/index.html index b40a1a7..8c19009 100644 --- a/test/integration/index.html +++ b/test/integration/index.html @@ -1,17 +1,19 @@ - +
-