1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-29 04:12:18 -05:00

WIP add unit tests

This commit is contained in:
Felix Hammerl 2014-10-07 20:32:23 +02:00
parent c36cd069e0
commit 9bfda73969
40 changed files with 9527 additions and 9675 deletions

2
.gitignore vendored
View File

@ -8,3 +8,5 @@ dist/
release/ release/
test/integration/src/ test/integration/src/
.elasticbeanstalk/ .elasticbeanstalk/
test/unit/index.js
test/unit/index.js.map

View File

@ -18,19 +18,18 @@
"unused": true, "unused": true,
"predef": [ "predef": [
"console",
"Notification",
"importScripts",
"process",
"Event",
"chrome",
"define",
"self", "self",
"describe", "console",
"it", "process",
"chai", "chrome",
"Notification",
"Event",
"sinon", "sinon",
"mocha", "mocha",
"chai",
"expect",
"describe",
"it",
"before", "before",
"beforeEach", "beforeEach",
"after", "after",

View File

@ -1,6 +1,8 @@
module.exports = function(grunt) { module.exports = function(grunt) {
'use strict'; 'use strict';
require('time-grunt')(grunt);
var version = grunt.option('release'), var version = grunt.option('release'),
zipName = (version) ? version : 'DEV'; zipName = (version) ? version : 'DEV';
@ -24,7 +26,7 @@ module.exports = function(grunt) {
}, },
jshint: { jshint: {
all: ['Gruntfile.js', 'src/*.js', 'src/js/**/*.js', 'test/unit/*.js', 'test/integration/*.js'], all: ['Gruntfile.js', 'src/*.js', 'src/js/**/*.js', 'test/unit/*-test.js', 'test/integration/*.js'],
options: { options: {
jshintrc: '.jshintrc' jshintrc: '.jshintrc'
} }
@ -109,15 +111,21 @@ module.exports = function(grunt) {
'dist/js/app.min.js': ['src/js/app.js'] 'dist/js/app.min.js': ['src/js/app.js']
}, },
options: { options: {
external: ['node-forge', 'net', 'tls'] // common.js apis not required at build time external: []
} }
}, },
/* TODO: unitTest: {
tls-worker: {}, files: {
'test/unit/index.js': ['test/unit/*-test.js']
},
options: {
external: []
}
},
/*
TODO:
mailreader-worker: {}, mailreader-worker: {},
pbkdf2-worker: {}, pbkdf2-worker: {},
unitTest: {},
unitTest: {},
integrationTest: {} integrationTest: {}
*/ */
}, },
@ -126,6 +134,7 @@ module.exports = function(grunt) {
all: { all: {
files: { files: {
'dist/js/app.min.js': [ 'dist/js/app.min.js': [
'src/lib/openpgp/openpgp.js',
'src/lib/underscore/underscore-min.js', 'src/lib/underscore/underscore-min.js',
'node_modules/jquery/dist/jquery.min.js', 'node_modules/jquery/dist/jquery.min.js',
'src/lib/angular/angular.min.js', 'src/lib/angular/angular.min.js',
@ -142,6 +151,28 @@ module.exports = function(grunt) {
] ]
} }
}, },
unitTest: {
files: {
'test/unit/index.js': [
'src/lib/underscore/underscore-min.js',
'node_modules/jquery/dist/jquery.min.js',
'src/lib/openpgp/openpgp.js',
'src/lib/angular/angular.min.js',
'node_modules/angular-mocks/angular-mocks.js',
'src/lib/angular/angular-route.min.js',
'src/lib/angular/angular-animate.min.js',
'src/lib/ngtagsinput/ng-tags-input.min.js',
'src/lib/fastclick/fastclick.js',
'node_modules/ng-infinite-scroll/build/ng-infinite-scroll.min.js',
'src/lib/lawnchair/lawnchair-git.js',
'src/lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js',
'src/lib/lawnchair/lawnchair-adapter-indexed-db-git.js',
'node_modules/dompurify/purify.js',
'test/lib/angular-mocks.js',
'test/unit/index.js'
]
}
},
options: { options: {
banner: '/*! Copyright © <%= grunt.template.today("yyyy") %>, Whiteout Networks GmbH.*/\n' banner: '/*! Copyright © <%= grunt.template.today("yyyy") %>, Whiteout Networks GmbH.*/\n'
} }
@ -152,7 +183,7 @@ module.exports = function(grunt) {
expand: true, expand: true,
flatten: true, flatten: true,
cwd: 'node_modules/', cwd: 'node_modules/',
src: ['requirejs/require.js', 'mocha/mocha.css', 'mocha/mocha.js', 'chai/chai.js', 'sinon/pkg/sinon.js', 'angularjs/src/ngMock/angular-mocks.js', 'browsercrow/src/*.js', 'browsersmtp/src/*.js'], src: ['mocha/mocha.css', 'mocha/mocha.js', 'chai/chai.js', 'sinon/pkg/sinon.js', 'browsercrow/src/*.js', 'browsersmtp/src/*.js'],
dest: 'test/lib/' dest: 'test/lib/'
}, },
font: { font: {

View File

@ -46,6 +46,7 @@
"wo-smtpclient": "^0.3.8" "wo-smtpclient": "^0.3.8"
}, },
"devDependencies": { "devDependencies": {
"angular-mocks": "^1.2.25",
"angularjs": "https://github.com/whiteout-io/angular.js/tarball/npm-version", "angularjs": "https://github.com/whiteout-io/angular.js/tarball/npm-version",
"browsercrow": "https://github.com/whiteout-io/browsercrow/tarball/master", "browsercrow": "https://github.com/whiteout-io/browsercrow/tarball/master",
"browsersmtp": "https://github.com/whiteout-io/browsersmtp/tarball/master", "browsersmtp": "https://github.com/whiteout-io/browsersmtp/tarball/master",
@ -65,6 +66,7 @@
"grunt-manifest": "^0.4.0", "grunt-manifest": "^0.4.0",
"grunt-mocha": "~0.4.1", "grunt-mocha": "~0.4.1",
"mocha": "~1.13.0", "mocha": "~1.13.0",
"sinon": "~1.7.3" "sinon": "~1.7.3",
"time-grunt": "^1.0.0"
} }
} }

View File

@ -1,14 +1,11 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var mocks = angular.mocks,
angular = require('angular'), AccountCtrl = require('../../src/js/controller/account'),
mocks = require('angularMocks'), PGP = require('../../src/js/crypto/pgp'),
AccountCtrl = require('js/controller/account'), dl = require('../../src/js/util/download'),
PGP = require('js/crypto/pgp'), appController = require('../../src/js/app-controller'),
dl = require('js/util/download'), KeychainDAO = require('../../src/js/dao/keychain-dao');
appController = require('js/app-controller'),
KeychainDAO = require('js/dao/keychain-dao');
describe('Account Controller unit test', function() { describe('Account Controller unit test', function() {
var scope, accountCtrl, var scope, accountCtrl,
@ -98,4 +95,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,13 +1,10 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var mocks = angular.mocks,
angular = require('angular'), AddAccountCtrl = require('../../src/js/controller/add-account'),
mocks = require('angularMocks'), Auth = require('../../src/js/bo/auth'),
AddAccountCtrl = require('js/controller/add-account'), AdminDao = require('../../src/js/dao/admin-dao'),
Auth = require('js/bo/auth'), appController = require('../../src/js/app-controller');
AdminDao = require('js/dao/admin-dao'),
appController = require('js/app-controller');
describe('Add Account Controller unit test', function() { describe('Add Account Controller unit test', function() {
var scope, location, ctrl, authStub, origAuth, adminStub; var scope, location, ctrl, authStub, origAuth, adminStub;
@ -213,4 +210,3 @@ define(function(require) {
}); });
}); });
});

View File

@ -1,9 +1,7 @@
define(function(require) {
'use strict'; 'use strict';
var RestDAO = require('js/dao/rest-dao'), var RestDAO = require('../../src/js/dao/rest-dao'),
AdminDAO = require('js/dao/admin-dao'), AdminDAO = require('../../src/js/dao/admin-dao');
expect = chai.expect;
describe('Admin DAO unit tests', function() { describe('Admin DAO unit tests', function() {
@ -142,5 +140,3 @@ define(function(require) {
}); });
}); });
});

View File

@ -1,13 +1,11 @@
define(function(require) {
'use strict'; 'use strict';
var controller = require('js/app-controller'), var controller = require('../../src/js/app-controller'),
EmailDAO = require('js/dao/email-dao'), EmailDAO = require('../../src/js/dao/email-dao'),
OutboxBO = require('js/bo/outbox'), OutboxBO = require('../../src/js/bo/outbox'),
DeviceStorageDAO = require('js/dao/devicestorage-dao'), DeviceStorageDAO = require('../../src/js/dao/devicestorage-dao'),
UpdateHandler = require('js/util/update/update-handler'), UpdateHandler = require('../../src/js/util/update/update-handler'),
Auth = require('js/bo/auth'), Auth = require('../../src/js/bo/auth');
expect = chai.expect;
describe('App Controller unit tests', function() { describe('App Controller unit tests', function() {
var emailDaoStub, outboxStub, updateHandlerStub, appConfigStoreStub, devicestorageStub, isOnlineStub, authStub; var emailDaoStub, outboxStub, updateHandlerStub, appConfigStoreStub, devicestorageStub, isOnlineStub, authStub;
@ -210,4 +208,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,11 +1,9 @@
define(function(require) {
'use strict'; 'use strict';
var Auth = require('js/bo/auth'), var Auth = require('../../src/js/bo/auth'),
OAuth = require('js/util/oauth'), OAuth = require('../../src/js/util/oauth'),
PGP = require('js/crypto/pgp'), PGP = require('../../src/js/crypto/pgp'),
DeviceStorageDAO = require('js/dao/devicestorage-dao'), DeviceStorageDAO = require('../../src/js/dao/devicestorage-dao');
expect = chai.expect;
describe('Auth unit tests', function() { describe('Auth unit tests', function() {
// Constancts // Constancts
@ -375,4 +373,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,8 +1,6 @@
define(function(require) {
'use strict'; 'use strict';
var btnHandler = require('js/util/backbutton-handler'), var btnHandler = require('../../src/js/util/backbutton-handler');
expect = chai.expect;
describe('Backbutton Handler', function() { describe('Backbutton Handler', function() {
chai.Assertion.includeStack = true; chai.Assertion.includeStack = true;
@ -64,4 +62,3 @@ define(function(require) {
document.dispatchEvent(event); document.dispatchEvent(event);
}); });
}); });
});

View File

@ -1,12 +1,10 @@
define(function(require) {
'use strict'; 'use strict';
var ConnectionDoctor = require('js/util/connection-doctor'), var TCPSocket = require('tcp-socket'),
TCPSocket = require('tcp-socket'),
ImapClient = require('imap-client'), ImapClient = require('imap-client'),
SmtpClient = require('smtpclient'), SmtpClient = require('wo-smtpclient'),
cfg = require('js/app-config').config, ConnectionDoctor = require('../../src/js/util/connection-doctor'),
expect = chai.expect; cfg = require('../../src/js/app-config').config;
describe('Connection Doctor', function() { describe('Connection Doctor', function() {
var doctor; var doctor;
@ -411,4 +409,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,13 +1,10 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var mocks = angular.mocks,
angular = require('angular'), ContactsCtrl = require('../../src/js/controller/contacts'),
mocks = require('angularMocks'), appController = require('../../src/js/app-controller'),
ContactsCtrl = require('js/controller/contacts'), KeychainDAO = require('../../src/js/dao/keychain-dao'),
appController = require('js/app-controller'), PGP = require('../../src/js/crypto/pgp');
KeychainDAO = require('js/dao/keychain-dao'),
PGP = require('js/crypto/pgp');
describe('Contacts Controller unit test', function() { describe('Contacts Controller unit test', function() {
var scope, contactsCtrl, var scope, contactsCtrl,
@ -187,4 +184,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,10 +1,8 @@
define(function(require) {
'use strict'; 'use strict';
var Crypto = require('js/crypto/crypto'), var Crypto = require('../../src/js/crypto/crypto'),
util = require('js/crypto/util'), config = require('../../src/js/app-config').config,
config = require('js/app-config').config, util = require('crypto-lib').util;
expect = chai.expect;
describe('Crypto unit tests', function() { describe('Crypto unit tests', function() {
this.timeout(20000); this.timeout(20000);
@ -55,4 +53,3 @@ define(function(require) {
}); });
}); });
});

View File

@ -1,9 +1,7 @@
define(function(require) {
'use strict'; 'use strict';
var LawnchairDAO = require('js/dao/lawnchair-dao'), var LawnchairDAO = require('../../src/js/dao/lawnchair-dao'),
DeviceStorageDAO = require('js/dao/devicestorage-dao'), DeviceStorageDAO = require('../../src/js/dao/devicestorage-dao');
expect = chai.expect;
var testUser = 'test@example.com'; var testUser = 'test@example.com';
@ -101,5 +99,3 @@ define(function(require) {
}); });
}); });
});

View File

@ -1,10 +1,7 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var mocks = angular.mocks,
angular = require('angular'), DialogCtrl = require('../../src/js/controller/dialog');
mocks = require('angularMocks'),
DialogCtrl = require('js/controller/dialog');
describe('Dialog Controller unit test', function() { describe('Dialog Controller unit test', function() {
var scope, dialogCtrl; var scope, dialogCtrl;
@ -47,4 +44,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,16 +1,14 @@
define(function(require) {
'use strict'; 'use strict';
var EmailDAO = require('js/dao/email-dao'), var mailreader = require('mailreader'),
KeychainDAO = require('js/dao/keychain-dao'),
ImapClient = require('imap-client'), ImapClient = require('imap-client'),
PgpMailer = require('pgpmailer'), PgpMailer = require('pgpmailer'),
PgpBuilder = require('pgpbuilder'), PgpBuilder = require('pgpbuilder'),
PGP = require('js/crypto/pgp'), cfg = require('../../src/js/app-config').config,
DeviceStorageDAO = require('js/dao/devicestorage-dao'), EmailDAO = require('../../src/js/dao/email-dao'),
mailreader = require('mailreader'), KeychainDAO = require('../../src/js/dao/keychain-dao'),
cfg = require('js/app-config').config, PGP = require('../../src/js/crypto/pgp'),
expect = chai.expect; DeviceStorageDAO = require('../../src/js/dao/devicestorage-dao');
describe('Email DAO unit tests', function() { describe('Email DAO unit tests', function() {
@ -2301,4 +2299,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -9,11 +9,70 @@
<body> <body>
<div id="mocha"></div> <div id="mocha"></div>
<script>
//
// Polyfills
//
(function() {
'use strict';
// Mozilla bind polyfill because phantomjs is stupid
if (!Function.prototype.bind) {
Function.prototype.bind = function(oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
FNOP = function() {},
fBound = function() {
return fToBind.apply(this instanceof FNOP && oThis ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments)));
};
FNOP.prototype = this.prototype;
fBound.prototype = new FNOP();
return fBound;
};
}
// a warm round of applause for phantomjs for missing events
(function() {
function CustomEvent(event, params) {
params = params || {
bubbles: false,
cancelable: false,
detail: undefined
};
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
}
CustomEvent.prototype = window.Event.prototype;
window.CustomEvent = CustomEvent;
})();
})();
</script>
<script src="../lib/chai.js"></script> <script src="../lib/chai.js"></script>
<script src="../lib/sinon.js"></script>
<script src="../lib/mocha.js"></script> <script src="../lib/mocha.js"></script>
<script src="../lib/sinon.js"></script>
<script data-main="main.js" src="../../src/lib/require.js"></script> <script>
window.expect = chai.expect;
mocha.setup('bdd');
</script>
<script src="index.js"></script>
<script>
mocha.checkLeaks();
mocha.globals([]);
mocha.run();
</script>
</body> </body>
</html> </html>

View File

@ -1,9 +1,7 @@
define(function(require) {
'use strict'; 'use strict';
var RestDAO = require('js/dao/rest-dao'), var RestDAO = require('../../src/js/dao/rest-dao'),
InvitationDAO = require('js/dao/invitation-dao'), InvitationDAO = require('../../src/js/dao/invitation-dao');
expect = chai.expect;
describe('Invitation DAO unit tests', function() { describe('Invitation DAO unit tests', function() {
var restDaoStub, invitationDao, var restDaoStub, invitationDao,
@ -105,4 +103,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,13 +1,11 @@
define(function(require) {
'use strict'; 'use strict';
var LawnchairDAO = require('js/dao/lawnchair-dao'), var LawnchairDAO = require('../../src/js/dao/lawnchair-dao'),
PublicKeyDAO = require('js/dao/publickey-dao'), PublicKeyDAO = require('../../src/js/dao/publickey-dao'),
KeychainDAO = require('js/dao/keychain-dao'), KeychainDAO = require('../../src/js/dao/keychain-dao'),
PrivateKeyDAO = require('js/dao/privatekey-dao'), PrivateKeyDAO = require('../../src/js/dao/privatekey-dao'),
Crypto = require('js/crypto/crypto'), Crypto = require('../../src/js/crypto/crypto'),
PGP = require('js/crypto/pgp'), PGP = require('../../src/js/crypto/pgp');
expect = chai.expect;
var testUser = 'test@example.com'; var testUser = 'test@example.com';
@ -1382,5 +1380,3 @@ define(function(require) {
}); });
}); });
});

View File

@ -1,8 +1,6 @@
define(function(require) {
'use strict'; 'use strict';
var LawnchairDAO = require('js/dao/lawnchair-dao'), var LawnchairDAO = require('../../src/js/dao/lawnchair-dao');
expect = chai.expect;
var dbName = 'lawnchair@test.com'; var dbName = 'lawnchair@test.com';
@ -148,5 +146,3 @@ define(function(require) {
}); });
}); });
});

View File

@ -1,14 +1,11 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var mocks = angular.mocks,
angular = require('angular'), LoginCtrl = require('../../src/js/controller/login'),
mocks = require('angularMocks'), EmailDAO = require('../../src/js/dao/email-dao'),
LoginCtrl = require('js/controller/login'), Auth = require('../../src/js/bo/auth'),
EmailDAO = require('js/dao/email-dao'), appController = require('../../src/js/app-controller'),
Auth = require('js/bo/auth'), KeychainDAO = require('../../src/js/dao/keychain-dao');
appController = require('js/app-controller'),
KeychainDAO = require('js/dao/keychain-dao');
describe('Login Controller unit test', function() { describe('Login Controller unit test', function() {
var scope, location, ctrl, var scope, location, ctrl,
@ -235,4 +232,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,14 +1,11 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var Auth = require('../../src/js/bo/auth'),
angular = require('angular'), mocks = angular.mocks,
Auth = require('js/bo/auth'), LoginExistingCtrl = require('../../src/js/controller/login-existing'),
mocks = require('angularMocks'), EmailDAO = require('../../src/js/dao/email-dao'),
LoginExistingCtrl = require('js/controller/login-existing'), KeychainDAO = require('../../src/js/dao/keychain-dao'),
EmailDAO = require('js/dao/email-dao'), appController = require('../../src/js/app-controller');
KeychainDAO = require('js/dao/keychain-dao'),
appController = require('js/app-controller');
describe('Login (existing user) Controller unit test', function() { describe('Login (existing user) Controller unit test', function() {
var scope, location, ctrl, origEmailDao, emailDaoMock, var scope, location, ctrl, origEmailDao, emailDaoMock,
@ -114,4 +111,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,14 +1,11 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var Auth = require('../../src/js/bo/auth'),
angular = require('angular'), mocks = angular.mocks,
Auth = require('js/bo/auth'), LoginInitialCtrl = require('../../src/js/controller/login-initial'),
mocks = require('angularMocks'), PGP = require('../../src/js/crypto/pgp'),
LoginInitialCtrl = require('js/controller/login-initial'), EmailDAO = require('../../src/js/dao/email-dao'),
PGP = require('js/crypto/pgp'), appController = require('../../src/js/app-controller');
EmailDAO = require('js/dao/email-dao'),
appController = require('js/app-controller');
describe('Login (initial user) Controller unit test', function() { describe('Login (initial user) Controller unit test', function() {
var scope, ctrl, location, origEmailDao, emailDaoMock, var scope, ctrl, location, origEmailDao, emailDaoMock,
@ -197,6 +194,4 @@ define(function(require) {
scope.generateKey(); scope.generateKey();
}); });
}); });
});
}); });

View File

@ -1,14 +1,11 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var mocks = angular.mocks,
angular = require('angular'), PGP = require('../../src/js/crypto/pgp'),
mocks = require('angularMocks'), LoginNewDeviceCtrl = require('../../src/js/controller/login-new-device'),
PGP = require('js/crypto/pgp'), KeychainDAO = require('../../src/js/dao/keychain-dao'),
LoginNewDeviceCtrl = require('js/controller/login-new-device'), EmailDAO = require('../../src/js/dao/email-dao'),
KeychainDAO = require('js/dao/keychain-dao'), appController = require('../../src/js/app-controller');
EmailDAO = require('js/dao/email-dao'),
appController = require('js/app-controller');
describe('Login (new device) Controller unit test', function() { describe('Login (new device) Controller unit test', function() {
var scope, ctrl, origEmailDao, emailDaoMock, pgpMock, var scope, ctrl, origEmailDao, emailDaoMock, pgpMock,
@ -187,4 +184,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,14 +1,11 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var mocks = angular.mocks,
angular = require('angular'), Auth = require('../../src/js/bo/auth'),
mocks = require('angularMocks'), LoginPrivateKeyDownloadCtrl = require('../../src/js/controller/login-privatekey-download'),
Auth = require('js/bo/auth'), EmailDAO = require('../../src/js/dao/email-dao'),
LoginPrivateKeyDownloadCtrl = require('js/controller/login-privatekey-download'), appController = require('../../src/js/app-controller'),
EmailDAO = require('js/dao/email-dao'), KeychainDAO = require('../../src/js/dao/keychain-dao');
appController = require('js/app-controller'),
KeychainDAO = require('js/dao/keychain-dao');
describe('Login Private Key Download Controller unit test', function() { describe('Login Private Key Download Controller unit test', function() {
var scope, location, ctrl, var scope, location, ctrl,
@ -261,4 +258,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,13 +1,10 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var mocks = angular.mocks,
angular = require('angular'), Auth = require('../../src/js/bo/auth'),
mocks = require('angularMocks'), ConnectionDoctor = require('../../src/js/util/connection-doctor'),
Auth = require('js/bo/auth'), SetCredentialsCtrl = require('../../src/js/controller/login-set-credentials'),
ConnectionDoctor = require('js/util/connection-doctor'), appController = require('../../src/js/app-controller');
SetCredentialsCtrl = require('js/controller/login-set-credentials'),
appController = require('js/app-controller');
describe('Login (Set Credentials) Controller unit test', function() { describe('Login (Set Credentials) Controller unit test', function() {
// Angular parameters // Angular parameters
@ -98,4 +95,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,15 +1,12 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var mocks = angular.mocks,
angular = require('angular'), MailListCtrl = require('../../src/js/controller/mail-list'),
mocks = require('angularMocks'), EmailDAO = require('../../src/js/dao/email-dao'),
MailListCtrl = require('js/controller/mail-list'), DeviceStorageDAO = require('../../src/js/dao/devicestorage-dao'),
EmailDAO = require('js/dao/email-dao'), KeychainDAO = require('../../src/js/dao/keychain-dao'),
DeviceStorageDAO = require('js/dao/devicestorage-dao'), appController = require('../../src/js/app-controller'),
KeychainDAO = require('js/dao/keychain-dao'), notification = require('../../src/js/util/notification');
appController = require('js/app-controller'),
notification = require('js/util/notification');
chai.Assertion.includeStack = true; chai.Assertion.includeStack = true;
@ -448,4 +445,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,113 +0,0 @@
'use strict';
// Mozilla bind polyfill because phantomjs is stupid
if (!Function.prototype.bind) {
Function.prototype.bind = function(oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
FNOP = function() {},
fBound = function() {
return fToBind.apply(this instanceof FNOP && oThis ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments)));
};
FNOP.prototype = this.prototype;
fBound.prototype = new FNOP();
return fBound;
};
}
// a warm round of applause for phantomjs for missing events
(function() {
function CustomEvent(event, params) {
params = params || {
bubbles: false,
cancelable: false,
detail: undefined
};
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
}
CustomEvent.prototype = window.Event.prototype;
window.CustomEvent = CustomEvent;
})();
require(['../../src/require-config'], function() {
require.config({
baseUrl: '../../src/lib',
paths: {
angularMocks: '../../test/lib/angular-mocks'
},
shim: {
angularMocks: {
exports: 'angular.mock',
deps: ['angular']
}
}
});
// Start the main app logic.
require(['js/app-config', 'axe'], function(app, axe) {
app.config.workerPath = '../../src/js';
// turn off logging in the test
axe.removeAppender(axe.defaultAppender);
startTests();
});
});
function startTests() {
mocha.setup('bdd');
require(
[
'test/unit/oauth-test',
'test/unit/auth-test',
'test/unit/email-dao-test',
'test/unit/app-controller-test',
'test/unit/pgp-test',
'test/unit/crypto-test',
'test/unit/backbutton-handler-test',
'test/unit/rest-dao-test',
'test/unit/admin-dao-test',
'test/unit/publickey-dao-test',
'test/unit/privatekey-dao-test',
'test/unit/lawnchair-dao-test',
'test/unit/keychain-dao-test',
'test/unit/devicestorage-dao-test',
'test/unit/dialog-ctrl-test',
'test/unit/add-account-ctrl-test',
'test/unit/account-ctrl-test',
'test/unit/set-passphrase-ctrl-test',
'test/unit/contacts-ctrl-test',
'test/unit/login-existing-ctrl-test',
'test/unit/login-initial-ctrl-test',
'test/unit/login-new-device-ctrl-test',
'test/unit/login-privatekey-download-ctrl-test',
'test/unit/login-set-credentials-ctrl-test',
'test/unit/privatekey-upload-ctrl-test',
'test/unit/login-ctrl-test',
'test/unit/read-ctrl-test',
'test/unit/navigation-ctrl-test',
'test/unit/mail-list-ctrl-test',
'test/unit/write-ctrl-test',
'test/unit/outbox-bo-test',
'test/unit/invitation-dao-test',
'test/unit/update-handler-test',
'test/unit/connection-doctor-test'
], function() {
//Tests loaded, run tests
mocha.run();
}
);
}

View File

@ -1,13 +1,10 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var mocks = angular.mocks,
angular = require('angular'), NavigationCtrl = require('../../src/js/controller/navigation'),
mocks = require('angularMocks'), EmailDAO = require('../../src/js/dao/email-dao'),
NavigationCtrl = require('js/controller/navigation'), OutboxBO = require('../../src/js/bo/outbox'),
EmailDAO = require('js/dao/email-dao'), appController = require('../../src/js/app-controller');
OutboxBO = require('js/bo/outbox'),
appController = require('js/app-controller');
describe('Navigation Controller unit test', function() { describe('Navigation Controller unit test', function() {
var scope, ctrl, origEmailDao, emailDaoMock, outboxBoMock, outboxFolder, onConnectStub; var scope, ctrl, origEmailDao, emailDaoMock, outboxBoMock, outboxFolder, onConnectStub;
@ -98,4 +95,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,9 +1,7 @@
define(function(require) {
'use strict'; 'use strict';
var OAuth = require('js/util/oauth'), var OAuth = require('../../src/js/util/oauth'),
RestDAO = require('js/dao/rest-dao'), RestDAO = require('../../src/js/dao/rest-dao');
expect = chai.expect;
describe('OAuth unit tests', function() { describe('OAuth unit tests', function() {
var oauth, googleApiStub, identityStub, getPlatformInfoStub, removeCachedStub, var oauth, googleApiStub, identityStub, getPlatformInfoStub, removeCachedStub,
@ -198,4 +196,3 @@ define(function(require) {
}); });
}); });
});

View File

@ -1,11 +1,9 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var OutboxBO = require('../../src/js/bo/outbox'),
OutboxBO = require('js/bo/outbox'), KeychainDAO = require('../../src/js/dao/keychain-dao'),
KeychainDAO = require('js/dao/keychain-dao'), EmailDAO = require('../../src/js/dao/email-dao'),
EmailDAO = require('js/dao/email-dao'), DeviceStorageDAO = require('../../src/js/dao/devicestorage-dao');
DeviceStorageDAO = require('js/dao/devicestorage-dao');
chai.Assertion.includeStack = true; chai.Assertion.includeStack = true;
@ -277,4 +275,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,9 +1,6 @@
define(function(require) {
'use strict'; 'use strict';
var PGP = require('js/crypto/pgp'), var PGP = require('../../src/js/crypto/pgp');
openpgp = require('openpgp'),
expect = chai.expect;
describe('PGP Crypto Api unit tests', function() { describe('PGP Crypto Api unit tests', function() {
this.timeout(20000); this.timeout(20000);
@ -461,4 +458,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,9 +1,7 @@
define(function(require) {
'use strict'; 'use strict';
var RestDAO = require('js/dao/rest-dao'), var RestDAO = require('../../src/js/dao/rest-dao'),
PrivateKeyDAO = require('js/dao/privatekey-dao'), PrivateKeyDAO = require('../../src/js/dao/privatekey-dao');
expect = chai.expect;
describe('Private Key DAO unit tests', function() { describe('Private Key DAO unit tests', function() {
@ -222,5 +220,3 @@ define(function(require) {
}); });
}); });
});

View File

@ -1,13 +1,10 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var mocks = angular.mocks,
angular = require('angular'), PrivateKeyUploadCtrl = require('../../src/js/controller/privatekey-upload'),
mocks = require('angularMocks'), appController = require('../../src/js/app-controller'),
PrivateKeyUploadCtrl = require('js/controller/privatekey-upload'), KeychainDAO = require('../../src/js/dao/keychain-dao'),
appController = require('js/app-controller'), PGP = require('../../src/js/crypto/pgp');
KeychainDAO = require('js/dao/keychain-dao'),
PGP = require('js/crypto/pgp');
describe('Private Key Upload Controller unit test', function() { describe('Private Key Upload Controller unit test', function() {
var scope, location, ctrl, var scope, location, ctrl,
@ -281,6 +278,4 @@ define(function(require) {
scope.goForward(); scope.goForward();
}); });
}); });
});
}); });

View File

@ -1,9 +1,7 @@
define(function(require) {
'use strict'; 'use strict';
var RestDAO = require('js/dao/rest-dao'), var RestDAO = require('../../src/js/dao/rest-dao'),
PublicKeyDAO = require('js/dao/publickey-dao'), PublicKeyDAO = require('../../src/js/dao/publickey-dao');
expect = chai.expect;
describe('Public Key DAO unit tests', function() { describe('Public Key DAO unit tests', function() {
@ -161,5 +159,3 @@ define(function(require) {
}); });
}); });
});

View File

@ -1,15 +1,12 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var mocks = angular.mocks,
angular = require('angular'), KeychainDAO = require('../../src/js/dao/keychain-dao'),
mocks = require('angularMocks'), InvitationDAO = require('../../src/js/dao/invitation-dao'),
KeychainDAO = require('js/dao/keychain-dao'), PGP = require('../../src/js/crypto/pgp'),
InvitationDAO = require('js/dao/invitation-dao'), ReadCtrl = require('../../src/js/controller/read'),
PGP = require('js/crypto/pgp'), OutboxBO = require('../../src/js/bo/outbox'),
ReadCtrl = require('js/controller/read'), appController = require('../../src/js/app-controller');
OutboxBO = require('js/bo/outbox'),
appController = require('js/app-controller');
describe('Read Controller unit test', function() { describe('Read Controller unit test', function() {
var scope, ctrl, var scope, ctrl,
@ -194,4 +191,3 @@ define(function(require) {
}); });
}); });
});

View File

@ -1,8 +1,6 @@
define(function(require) {
'use strict'; 'use strict';
var RestDAO = require('js/dao/rest-dao'), var RestDAO = require('../../src/js/dao/rest-dao');
expect = chai.expect;
describe('Rest DAO unit tests', function() { describe('Rest DAO unit tests', function() {
@ -221,5 +219,3 @@ define(function(require) {
}); });
}); });
});

View File

@ -1,13 +1,10 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var mocks = angular.mocks,
angular = require('angular'), SetPassphraseCtrl = require('../../src/js/controller/set-passphrase'),
mocks = require('angularMocks'), PGP = require('../../src/js/crypto/pgp'),
SetPassphraseCtrl = require('js/controller/set-passphrase'), appController = require('../../src/js/app-controller'),
PGP = require('js/crypto/pgp'), KeychainDAO = require('../../src/js/dao/keychain-dao');
appController = require('js/app-controller'),
KeychainDAO = require('js/dao/keychain-dao');
describe('Set Passphrase Controller unit test', function() { describe('Set Passphrase Controller unit test', function() {
var scope, setPassphraseCtrl, var scope, setPassphraseCtrl,
@ -123,4 +120,3 @@ define(function(require) {
}); });
}); });
});

View File

@ -1,12 +1,10 @@
define(function(require) {
'use strict'; 'use strict';
var DeviceStorageDAO = require('js/dao/devicestorage-dao'), var DeviceStorageDAO = require('../../src/js/dao/devicestorage-dao'),
Auth = require('js/bo/auth'), Auth = require('../../src/js/bo/auth'),
cfg = require('js/app-config').config, cfg = require('../../src/js/app-config').config,
UpdateHandler = require('js/util/update/update-handler'), UpdateHandler = require('../../src/js/util/update/update-handler'),
config = require('js/app-config').config, config = require('../../src/js/app-config').config;
expect = chai.expect;
describe('UpdateHandler', function() { describe('UpdateHandler', function() {
var updateHandler, appConfigStorageStub, authStub, userStorageStub, origDbVersion; var updateHandler, appConfigStorageStub, authStub, userStorageStub, origDbVersion;
@ -471,4 +469,3 @@ define(function(require) {
}); });
}); });
}); });
});

View File

@ -1,14 +1,11 @@
define(function(require) {
'use strict'; 'use strict';
var expect = chai.expect, var mocks = angular.mocks,
angular = require('angular'), WriteCtrl = require('../../src/js/controller/write'),
mocks = require('angularMocks'), EmailDAO = require('../../src/js/dao/email-dao'),
WriteCtrl = require('js/controller/write'), OutboxBO = require('../../src/js/bo/outbox'),
EmailDAO = require('js/dao/email-dao'), KeychainDAO = require('../../src/js/dao/keychain-dao'),
OutboxBO = require('js/bo/outbox'), appController = require('../../src/js/app-controller');
KeychainDAO = require('js/dao/keychain-dao'),
appController = require('js/app-controller');
describe('Write controller unit test', function() { describe('Write controller unit test', function() {
var ctrl, scope, var ctrl, scope,
@ -398,4 +395,3 @@ define(function(require) {
}); });
}); });
});