mirror of
https://github.com/moparisthebest/mail
synced 2024-11-28 20:02:16 -05:00
implement integration test in chrome app
This commit is contained in:
parent
093f9a58e8
commit
567a2d19ed
4
.gitignore
vendored
4
.gitignore
vendored
@ -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
|
||||
|
12
Gruntfile.js
12
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/'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
10
test/integration/background.js
Normal file
10
test/integration/background.js
Normal file
@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
chrome.app.runtime.onLaunched.addListener(function() {
|
||||
chrome.app.window.create('integration/index.html', {
|
||||
'bounds': {
|
||||
'width': 1024,
|
||||
'height': 768
|
||||
}
|
||||
});
|
||||
});
|
67
test/integration/email-dao-test.js
Normal file
67
test/integration/email-dao-test.js
Normal file
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
@ -1,17 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html style="overflow-y: auto">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>JavaScript Integration Tests</title>
|
||||
<link rel="stylesheet" href="../qunit-1.11.0.css">
|
||||
<title>JavaScript Unit Tests</title>
|
||||
<link rel="stylesheet" href="../lib/mocha.css" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<div id="mocha"></div>
|
||||
|
||||
<script src="../qunit-1.11.0.js"></script>
|
||||
<script>QUnit.config.autostart = false;</script>
|
||||
<script data-main="main.js" src="../../src/lib/require.js"></script>
|
||||
<script src="../lib/chai.js"></script>
|
||||
<script src="../lib/sinon.js"></script>
|
||||
<script src="../lib/mocha.js"></script>
|
||||
|
||||
<script data-main="main.js" src="../lib/require.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,27 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
require(['../../src/require-config'], function() {
|
||||
|
||||
require(['src/require-config'], function() {
|
||||
require.config({
|
||||
baseUrl: '../../src/lib'
|
||||
baseUrl: 'src/lib'
|
||||
});
|
||||
|
||||
// Start the main app logic.
|
||||
require(['js/app-config', 'cordova'], function(app) {
|
||||
// clear session storage of failed tests, so async order is correct after fail & refresh
|
||||
window.sessionStorage.clear();
|
||||
window.Worker = undefined;
|
||||
require(['js/app-config'], function(app) {
|
||||
window.Worker = undefined; // disable web workers since mocha doesn't support them
|
||||
|
||||
app.config.workerPath = '../../src/js';
|
||||
app.config.cloudUrl = 'http://localhost:8888';
|
||||
//app.config.cloudUrl = 'http://localhost:8888';
|
||||
|
||||
startTests();
|
||||
});
|
||||
});
|
||||
|
||||
function startTests() {
|
||||
require(['test/integration/cloudstorage-dao-test'], function() {
|
||||
mocha.setup('bdd');
|
||||
|
||||
require(
|
||||
[
|
||||
'../../email-dao-test'
|
||||
], function() {
|
||||
//Tests loaded, run tests
|
||||
QUnit.start();
|
||||
});
|
||||
mocha.run();
|
||||
}
|
||||
);
|
||||
}
|
26
test/manifest.json
Normal file
26
test/manifest.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "Whiteout Mail Integration Tests",
|
||||
"description": "",
|
||||
"version": "0.0.1",
|
||||
"manifest_version": 2,
|
||||
"offline_enabled": true,
|
||||
"permissions": [
|
||||
"https://storage.whiteout.io/",
|
||||
"identity", {
|
||||
"socket": ["tcp-connect"]
|
||||
}
|
||||
],
|
||||
"key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBXqC3/oX5fP/gLORcVN62Pf3Ph+pO4qEB+FynSMWMoqWUt7FDoaKuHrsP/KInuP/0PUZcqpij9kB9MytLTqYzGIoRsUd37i1Dt6R69fnNsIqAISgoWIRg4VyRdon9cTIniv3DVV45PPyNCvN+oQoBMv9NbojWnlL9W05bKYkABQIDAQAB",
|
||||
"oauth2": {
|
||||
"client_id": "440907777130.apps.googleusercontent.com",
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/userinfo.email",
|
||||
"https://mail.google.com/"
|
||||
]
|
||||
},
|
||||
"app": {
|
||||
"background": {
|
||||
"scripts": ["integration/background.js"]
|
||||
}
|
||||
}
|
||||
}
|
@ -3,15 +3,15 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>JavaScript Unit Tests</title>
|
||||
<link rel="stylesheet" href="lib/mocha.css" />
|
||||
<link rel="stylesheet" href="../lib/mocha.css" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
|
||||
<script src="lib/chai.js"></script>
|
||||
<script src="lib/sinon.js"></script>
|
||||
<script src="lib/mocha.js"></script>
|
||||
<script src="../lib/chai.js"></script>
|
||||
<script src="../lib/sinon.js"></script>
|
||||
<script src="../lib/mocha.js"></script>
|
||||
|
||||
<script data-main="main.js" src="../../src/lib/require.js"></script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user