mirror of
https://github.com/moparisthebest/mail
synced 2025-02-19 20:31:48 -05:00
Fix unit tests for existing angular services
This commit is contained in:
parent
881afbff40
commit
f2fee61d3b
55
Gruntfile.js
55
Gruntfile.js
@ -155,23 +155,29 @@ module.exports = function(grunt) {
|
|||||||
unitTest: {
|
unitTest: {
|
||||||
files: {
|
files: {
|
||||||
'test/unit/index.browserified.js': [
|
'test/unit/index.browserified.js': [
|
||||||
'test/unit/oauth-test.js',
|
'test/main.js',
|
||||||
'test/unit/auth-test.js',
|
'test/unit/util/dialog-test.js',
|
||||||
'test/unit/email-dao-test.js',
|
'test/unit/util/connection-doctor-test.js',
|
||||||
'test/unit/app-controller-test.js',
|
'test/unit/util/update-handler-test.js',
|
||||||
'test/unit/pgp-test.js',
|
'test/unit/util/backbutton-handler-test.js',
|
||||||
'test/unit/crypto-test.js',
|
'test/unit/util/status-display-test.js',
|
||||||
'test/unit/backbutton-handler-test.js',
|
'test/unit/crypto/pgp-test.js',
|
||||||
'test/unit/rest-dao-test.js',
|
'test/unit/crypto/crypto-test.js',
|
||||||
'test/unit/admin-dao-test.js',
|
'test/unit/service/rest-dao-test.js',
|
||||||
'test/unit/publickey-dao-test.js',
|
'test/unit/service/admin-dao-test.js',
|
||||||
'test/unit/privatekey-dao-test.js',
|
'test/unit/service/auth-test.js',
|
||||||
'test/unit/lawnchair-dao-test.js',
|
'test/unit/service/oauth-test.js',
|
||||||
'test/unit/keychain-dao-test.js',
|
'test/unit/service/publickey-dao-test.js',
|
||||||
'test/unit/devicestorage-dao-test.js',
|
'test/unit/service/privatekey-dao-test.js',
|
||||||
'test/unit/newsletter-service-test.js',
|
'test/unit/service/lawnchair-dao-test.js',
|
||||||
'test/unit/mail-config-service-test.js',
|
'test/unit/service/keychain-dao-test.js',
|
||||||
'test/unit/dialog-ctrl-test.js',
|
'test/unit/service/devicestorage-dao-test.js',
|
||||||
|
'test/unit/service/newsletter-service-test.js',
|
||||||
|
'test/unit/service/mail-config-service-test.js',
|
||||||
|
'test/unit/service/invitation-dao-test.js',
|
||||||
|
'test/unit/email/outbox-bo-test.js',
|
||||||
|
'test/unit/email/email-dao-test.js',
|
||||||
|
/*'test/unit/dialog-ctrl-test.js',
|
||||||
'test/unit/add-account-ctrl-test.js',
|
'test/unit/add-account-ctrl-test.js',
|
||||||
'test/unit/create-account-ctrl-test.js',
|
'test/unit/create-account-ctrl-test.js',
|
||||||
'test/unit/validate-phone-ctrl-test.js',
|
'test/unit/validate-phone-ctrl-test.js',
|
||||||
@ -189,12 +195,7 @@ module.exports = function(grunt) {
|
|||||||
'test/unit/navigation-ctrl-test.js',
|
'test/unit/navigation-ctrl-test.js',
|
||||||
'test/unit/mail-list-ctrl-test.js',
|
'test/unit/mail-list-ctrl-test.js',
|
||||||
'test/unit/write-ctrl-test.js',
|
'test/unit/write-ctrl-test.js',
|
||||||
'test/unit/action-bar-ctrl-test.js',
|
'test/unit/action-bar-ctrl-test.js',*/
|
||||||
'test/unit/outbox-bo-test.js',
|
|
||||||
'test/unit/invitation-dao-test.js',
|
|
||||||
'test/unit/update-handler-test.js',
|
|
||||||
'test/unit/connection-doctor-test.js',
|
|
||||||
'test/main.js'
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
options: browserifyOpt
|
options: browserifyOpt
|
||||||
@ -202,8 +203,8 @@ module.exports = function(grunt) {
|
|||||||
integrationTest: {
|
integrationTest: {
|
||||||
files: {
|
files: {
|
||||||
'test/integration/index.browserified.js': [
|
'test/integration/index.browserified.js': [
|
||||||
'test/integration/email-dao-test.js',
|
'test/main.js',
|
||||||
'test/main.js'
|
/*'test/integration/email-dao-test.js'*/
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
options: browserifyOpt
|
options: browserifyOpt
|
||||||
@ -446,11 +447,11 @@ module.exports = function(grunt) {
|
|||||||
tasks: ['dist-js-app']
|
tasks: ['dist-js-app']
|
||||||
},
|
},
|
||||||
jsUnitTest: {
|
jsUnitTest: {
|
||||||
files: ['test/unit/*-test.js'],
|
files: ['test/unit/**/*-test.js', 'test/*.js'],
|
||||||
tasks: ['dist-js-unitTest']
|
tasks: ['dist-js-unitTest']
|
||||||
},
|
},
|
||||||
jsIntegrationTest: {
|
jsIntegrationTest: {
|
||||||
files: ['test/integration/*-test.js'],
|
files: ['test/integration/*-test.js', 'test/*.js'],
|
||||||
tasks: ['dist-js-integrationTest']
|
tasks: ['dist-js-integrationTest']
|
||||||
},
|
},
|
||||||
icons: {
|
icons: {
|
||||||
|
@ -57,9 +57,7 @@ function Email(keychain, pgp, accountStore, pgpbuilder, mailreader, dialog) {
|
|||||||
this._pgpbuilder = pgpbuilder;
|
this._pgpbuilder = pgpbuilder;
|
||||||
this._mailreader = mailreader;
|
this._mailreader = mailreader;
|
||||||
|
|
||||||
this.onError = function(err) {
|
this.onError = dialog.error.bind(dialog);
|
||||||
dialog.error(err);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,6 +6,10 @@ ngModule.factory('deviceStorage', function(lawnchairDAO) {
|
|||||||
});
|
});
|
||||||
module.exports = DeviceStorage;
|
module.exports = DeviceStorage;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Export special device storage singletons
|
||||||
|
//
|
||||||
|
|
||||||
// expose an instance with the static dbName 'app-config' to store configuration data
|
// expose an instance with the static dbName 'app-config' to store configuration data
|
||||||
ngModule.factory('appConfigStore', function(deviceStorage) {
|
ngModule.factory('appConfigStore', function(deviceStorage) {
|
||||||
deviceStorage.init('app-config');
|
deviceStorage.init('app-config');
|
||||||
@ -15,6 +19,10 @@ ngModule.factory('appConfigStore', function(deviceStorage) {
|
|||||||
// expose a singleton instance of DeviceStorage called 'accountStore' to persist user data
|
// expose a singleton instance of DeviceStorage called 'accountStore' to persist user data
|
||||||
ngModule.service('accountStore', DeviceStorage);
|
ngModule.service('accountStore', DeviceStorage);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Implementation
|
||||||
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* High level storage api that handles all persistence of a user's data on the device.
|
* High level storage api that handles all persistence of a user's data on the device.
|
||||||
*/
|
*/
|
||||||
@ -22,6 +30,10 @@ function DeviceStorage(lawnchairDAO) {
|
|||||||
this._lawnchairDAO = lawnchairDAO;
|
this._lawnchairDAO = lawnchairDAO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the lawnchair database
|
||||||
|
* @param {String} dbName The name of the database
|
||||||
|
*/
|
||||||
DeviceStorage.prototype.init = function(dbName) {
|
DeviceStorage.prototype.init = function(dbName) {
|
||||||
this._lawnchairDAO.init(dbName);
|
this._lawnchairDAO.init(dbName);
|
||||||
};
|
};
|
||||||
|
@ -4,8 +4,7 @@ var ngModule = angular.module('woServices');
|
|||||||
ngModule.service('keychain', Keychain);
|
ngModule.service('keychain', Keychain);
|
||||||
module.exports = Keychain;
|
module.exports = Keychain;
|
||||||
|
|
||||||
var util = require('crypto-lib').util,
|
var util = require('crypto-lib').util;
|
||||||
config = require('../app-config').config;
|
|
||||||
|
|
||||||
var DB_PUBLICKEY = 'publickey',
|
var DB_PUBLICKEY = 'publickey',
|
||||||
DB_PRIVATEKEY = 'privatekey',
|
DB_PRIVATEKEY = 'privatekey',
|
||||||
@ -327,7 +326,8 @@ Keychain.prototype.getDeviceName = function(callback) {
|
|||||||
* @param {Function} callback(error, deviceSecret:[base64 encoded string])
|
* @param {Function} callback(error, deviceSecret:[base64 encoded string])
|
||||||
*/
|
*/
|
||||||
Keychain.prototype.getDeviceSecret = function(callback) {
|
Keychain.prototype.getDeviceSecret = function(callback) {
|
||||||
var self = this;
|
var self = this,
|
||||||
|
config = self._appConfig.config;
|
||||||
|
|
||||||
// generate random deviceSecret or get from storage
|
// generate random deviceSecret or get from storage
|
||||||
self._lawnchairDAO.read(DB_DEVICE_SECRET, function(err, storedDevSecret) {
|
self._lawnchairDAO.read(DB_DEVICE_SECRET, function(err, storedDevSecret) {
|
||||||
@ -363,7 +363,8 @@ Keychain.prototype.getDeviceSecret = function(callback) {
|
|||||||
*/
|
*/
|
||||||
Keychain.prototype.registerDevice = function(options, callback) {
|
Keychain.prototype.registerDevice = function(options, callback) {
|
||||||
var self = this,
|
var self = this,
|
||||||
devName;
|
devName,
|
||||||
|
config = self._appConfig.config;
|
||||||
|
|
||||||
// check if deviceName is already persisted in storage
|
// check if deviceName is already persisted in storage
|
||||||
self.getDeviceName(function(err, deviceName) {
|
self.getDeviceName(function(err, deviceName) {
|
||||||
@ -462,7 +463,8 @@ Keychain.prototype.registerDevice = function(options, callback) {
|
|||||||
*/
|
*/
|
||||||
Keychain.prototype._authenticateToPrivateKeyServer = function(userId, callback) {
|
Keychain.prototype._authenticateToPrivateKeyServer = function(userId, callback) {
|
||||||
var self = this,
|
var self = this,
|
||||||
sessionId;
|
sessionId,
|
||||||
|
config = self._appConfig.config;
|
||||||
|
|
||||||
// request auth session key required for upload
|
// request auth session key required for upload
|
||||||
self._privateKeyDao.requestAuthSessionKey({
|
self._privateKeyDao.requestAuthSessionKey({
|
||||||
@ -579,6 +581,7 @@ Keychain.prototype._authenticateToPrivateKeyServer = function(userId, callback)
|
|||||||
*/
|
*/
|
||||||
Keychain.prototype.uploadPrivateKey = function(options, callback) {
|
Keychain.prototype.uploadPrivateKey = function(options, callback) {
|
||||||
var self = this,
|
var self = this,
|
||||||
|
config = self._appConfig.config,
|
||||||
keySize = config.symKeySize,
|
keySize = config.symKeySize,
|
||||||
salt;
|
salt;
|
||||||
|
|
||||||
@ -710,6 +713,7 @@ Keychain.prototype.decryptAndStorePrivateKeyLocally = function(options, callback
|
|||||||
var self = this,
|
var self = this,
|
||||||
code = options.code,
|
code = options.code,
|
||||||
salt = options.salt,
|
salt = options.salt,
|
||||||
|
config = self._appConfig.config,
|
||||||
keySize = config.symKeySize;
|
keySize = config.symKeySize;
|
||||||
|
|
||||||
if (!options._id || !options.userId || !options.code || !options.salt || !options.encryptedPrivateKey || !options.iv) {
|
if (!options._id || !options.userId || !options.code || !options.salt || !options.encryptedPrivateKey || !options.iv) {
|
||||||
|
@ -20,7 +20,7 @@ MailConfig.prototype.get = function(emailAddress) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = this._appConfig.settingsUrl + emailAddress.split('@')[1];
|
var url = this._appConfig.config.settingsUrl + emailAddress.split('@')[1];
|
||||||
return this._http.get(url).then(function(res) {
|
return this._http.get(url).then(function(res) {
|
||||||
return res.data;
|
return res.data;
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var Crypto = require('../../src/js/crypto/crypto'),
|
var Crypto = require('../../../src/js/crypto/crypto'),
|
||||||
config = require('../../src/js/app-config').config,
|
config = require('../../../src/js/app-config').config,
|
||||||
util = require('crypto-lib').util;
|
util = require('crypto-lib').util;
|
||||||
|
|
||||||
describe('Crypto unit tests', function() {
|
describe('Crypto unit tests', function() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var PGP = require('../../src/js/crypto/pgp');
|
var PGP = require('../../../src/js/crypto/pgp');
|
||||||
|
|
||||||
describe('PGP Crypto Api unit tests', function() {
|
describe('PGP Crypto Api unit tests', function() {
|
||||||
this.timeout(20000);
|
this.timeout(20000);
|
||||||
|
@ -4,11 +4,12 @@ var mailreader = require('mailreader'),
|
|||||||
ImapClient = require('imap-client'),
|
ImapClient = require('imap-client'),
|
||||||
PgpMailer = require('pgpmailer'),
|
PgpMailer = require('pgpmailer'),
|
||||||
PgpBuilder = require('pgpbuilder'),
|
PgpBuilder = require('pgpbuilder'),
|
||||||
cfg = require('../../src/js/app-config').config,
|
cfg = require('../../../src/js/app-config').config,
|
||||||
EmailDAO = require('../../src/js/dao/email-dao'),
|
EmailDAO = require('../../../src/js/email/email'),
|
||||||
KeychainDAO = require('../../src/js/dao/keychain-dao'),
|
KeychainDAO = require('../../../src/js/service/keychain'),
|
||||||
PGP = require('../../src/js/crypto/pgp'),
|
PGP = require('../../../src/js/crypto/pgp'),
|
||||||
DeviceStorageDAO = require('../../src/js/dao/devicestorage-dao');
|
DeviceStorageDAO = require('../../../src/js/service/devicestorage'),
|
||||||
|
Dialog = require('../../../src/js/util/dialog');
|
||||||
|
|
||||||
|
|
||||||
describe('Email DAO unit tests', function() {
|
describe('Email DAO unit tests', function() {
|
||||||
@ -19,7 +20,7 @@ describe('Email DAO unit tests', function() {
|
|||||||
var dao;
|
var dao;
|
||||||
|
|
||||||
// mocks
|
// mocks
|
||||||
var keychainStub, imapClientStub, pgpMailerStub, pgpBuilderStub, pgpStub, devicestorageStub, parseStub;
|
var keychainStub, imapClientStub, pgpMailerStub, pgpBuilderStub, pgpStub, devicestorageStub, parseStub, dialogStub;
|
||||||
|
|
||||||
// config
|
// config
|
||||||
var emailAddress, passphrase, asymKeySize, account;
|
var emailAddress, passphrase, asymKeySize, account;
|
||||||
@ -116,11 +117,12 @@ describe('Email DAO unit tests', function() {
|
|||||||
pgpStub = sinon.createStubInstance(PGP);
|
pgpStub = sinon.createStubInstance(PGP);
|
||||||
parseStub = sinon.stub(mailreader, 'parse');
|
parseStub = sinon.stub(mailreader, 'parse');
|
||||||
devicestorageStub = sinon.createStubInstance(DeviceStorageDAO);
|
devicestorageStub = sinon.createStubInstance(DeviceStorageDAO);
|
||||||
|
dialogStub = sinon.createStubInstance(Dialog);
|
||||||
|
|
||||||
//
|
//
|
||||||
// setup the SUT
|
// setup the SUT
|
||||||
//
|
//
|
||||||
dao = new EmailDAO(keychainStub, pgpStub, devicestorageStub, pgpBuilderStub, mailreader);
|
dao = new EmailDAO(keychainStub, pgpStub, devicestorageStub, pgpBuilderStub, mailreader, dialogStub);
|
||||||
dao._account = account;
|
dao._account = account;
|
||||||
dao._pgpMailer = pgpMailerStub;
|
dao._pgpMailer = pgpMailerStub;
|
||||||
dao._imapClient = imapClientStub;
|
dao._imapClient = imapClientStub;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var OutboxBO = require('../../src/js/bo/outbox'),
|
var OutboxBO = require('../../../src/js/email/outbox'),
|
||||||
KeychainDAO = require('../../src/js/dao/keychain-dao'),
|
KeychainDAO = require('../../../src/js/service/keychain'),
|
||||||
EmailDAO = require('../../src/js/dao/email-dao'),
|
EmailDAO = require('../../../src/js/email/email'),
|
||||||
DeviceStorageDAO = require('../../src/js/dao/devicestorage-dao');
|
DeviceStorageDAO = require('../../../src/js/service/devicestorage');
|
||||||
|
|
||||||
describe('Outbox Business Object unit test', function() {
|
describe('Outbox Business Object unit test', function() {
|
||||||
var outbox, emailDaoStub, devicestorageStub, keychainStub,
|
var outbox, emailDaoStub, devicestorageStub, keychainStub,
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var RestDAO = require('../../src/js/dao/rest-dao'),
|
var RestDAO = require('../../../src/js/service/rest'),
|
||||||
AdminDAO = require('../../src/js/dao/admin-dao');
|
AdminDAO = require('../../../src/js/service/admin'),
|
||||||
|
appConfig = require('../../../src/js/app-config');
|
||||||
|
|
||||||
describe('Admin DAO unit tests', function() {
|
describe('Admin DAO unit tests', function() {
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ describe('Admin DAO unit tests', function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
restDaoStub = sinon.createStubInstance(RestDAO);
|
restDaoStub = sinon.createStubInstance(RestDAO);
|
||||||
adminDao = new AdminDAO(restDaoStub);
|
adminDao = new AdminDAO(restDaoStub, appConfig);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {});
|
afterEach(function() {});
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var Auth = require('../../src/js/bo/auth'),
|
var Auth = require('../../../src/js/service/auth'),
|
||||||
OAuth = require('../../src/js/util/oauth'),
|
OAuth = require('../../../src/js/service/oauth'),
|
||||||
PGP = require('../../src/js/crypto/pgp'),
|
PGP = require('../../../src/js/crypto/pgp'),
|
||||||
DeviceStorageDAO = require('../../src/js/dao/devicestorage-dao');
|
DeviceStorageDAO = require('../../../src/js/service/devicestorage');
|
||||||
|
|
||||||
describe('Auth unit tests', function() {
|
describe('Auth unit tests', function() {
|
||||||
// Constancts
|
// Constancts
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var LawnchairDAO = require('../../src/js/dao/lawnchair-dao'),
|
var LawnchairDAO = require('../../../src/js/service/lawnchair'),
|
||||||
DeviceStorageDAO = require('../../src/js/dao/devicestorage-dao');
|
DeviceStorageDAO = require('../../../src/js/service/devicestorage');
|
||||||
|
|
||||||
var testUser = 'test@example.com';
|
var testUser = 'test@example.com';
|
||||||
|
|
||||||
@ -17,14 +17,9 @@ describe('Device Storage DAO unit tests', function() {
|
|||||||
afterEach(function() {});
|
afterEach(function() {});
|
||||||
|
|
||||||
describe('init', function() {
|
describe('init', function() {
|
||||||
it('should work', function(done) {
|
it('should work', function() {
|
||||||
lawnchairDaoStub.init.yields();
|
storageDao.init(testUser);
|
||||||
|
|
||||||
storageDao.init(testUser, function(err) {
|
|
||||||
expect(err).to.not.exist;
|
|
||||||
expect(lawnchairDaoStub.init.calledOnce).to.be.true;
|
expect(lawnchairDaoStub.init.calledOnce).to.be.true;
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var RestDAO = require('../../src/js/dao/rest-dao'),
|
var RestDAO = require('../../../src/js/service/rest'),
|
||||||
InvitationDAO = require('../../src/js/dao/invitation-dao');
|
InvitationDAO = require('../../../src/js/service/invitation'),
|
||||||
|
appConfig = require('../../../src/js/app-config');
|
||||||
|
|
||||||
describe('Invitation DAO unit tests', function() {
|
describe('Invitation DAO unit tests', function() {
|
||||||
var restDaoStub, invitationDao,
|
var restDaoStub, invitationDao,
|
||||||
@ -11,7 +12,7 @@ describe('Invitation DAO unit tests', function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
restDaoStub = sinon.createStubInstance(RestDAO);
|
restDaoStub = sinon.createStubInstance(RestDAO);
|
||||||
invitationDao = new InvitationDAO(restDaoStub);
|
invitationDao = new InvitationDAO(restDaoStub, appConfig);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('initialization', function() {
|
describe('initialization', function() {
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var LawnchairDAO = require('../../src/js/dao/lawnchair-dao'),
|
var LawnchairDAO = require('../../../src/js/service/lawnchair'),
|
||||||
PublicKeyDAO = require('../../src/js/dao/publickey-dao'),
|
PublicKeyDAO = require('../../../src/js/service/publickey'),
|
||||||
KeychainDAO = require('../../src/js/dao/keychain-dao'),
|
KeychainDAO = require('../../../src/js/service/keychain'),
|
||||||
PrivateKeyDAO = require('../../src/js/dao/privatekey-dao'),
|
PrivateKeyDAO = require('../../../src/js/service/privatekey'),
|
||||||
Crypto = require('../../src/js/crypto/crypto'),
|
Crypto = require('../../../src/js/crypto/crypto'),
|
||||||
PGP = require('../../src/js/crypto/pgp');
|
PGP = require('../../../src/js/crypto/pgp'),
|
||||||
|
Dialog = require('../../../src/js/util/dialog'),
|
||||||
|
appConfig = require('../../../src/js/app-config');
|
||||||
|
|
||||||
var testUser = 'test@example.com';
|
var testUser = 'test@example.com';
|
||||||
|
|
||||||
describe('Keychain DAO unit tests', function() {
|
describe('Keychain DAO unit tests', function() {
|
||||||
|
|
||||||
var keychainDao, lawnchairDaoStub, pubkeyDaoStub, privkeyDaoStub, cryptoStub, pgpStub;
|
var keychainDao, lawnchairDaoStub, pubkeyDaoStub, privkeyDaoStub, cryptoStub, pgpStub, dialogStub;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
lawnchairDaoStub = sinon.createStubInstance(LawnchairDAO);
|
lawnchairDaoStub = sinon.createStubInstance(LawnchairDAO);
|
||||||
@ -19,11 +21,25 @@ describe('Keychain DAO unit tests', function() {
|
|||||||
privkeyDaoStub = sinon.createStubInstance(PrivateKeyDAO);
|
privkeyDaoStub = sinon.createStubInstance(PrivateKeyDAO);
|
||||||
cryptoStub = sinon.createStubInstance(Crypto);
|
cryptoStub = sinon.createStubInstance(Crypto);
|
||||||
pgpStub = sinon.createStubInstance(PGP);
|
pgpStub = sinon.createStubInstance(PGP);
|
||||||
keychainDao = new KeychainDAO(lawnchairDaoStub, pubkeyDaoStub, privkeyDaoStub, cryptoStub, pgpStub);
|
dialogStub = sinon.createStubInstance(Dialog);
|
||||||
|
keychainDao = new KeychainDAO(lawnchairDaoStub, pubkeyDaoStub, privkeyDaoStub, cryptoStub, pgpStub, dialogStub, appConfig);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {});
|
afterEach(function() {});
|
||||||
|
|
||||||
|
describe('requestPermissionForKeyUpdate', function() {
|
||||||
|
it('should work', function() {
|
||||||
|
var opt = {
|
||||||
|
newKey: {},
|
||||||
|
userId: 'asdf@example.com'
|
||||||
|
};
|
||||||
|
|
||||||
|
keychainDao.requestPermissionForKeyUpdate(opt, function() {
|
||||||
|
expect(dialogStub.confirm.calledOnce).to.be.true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('verify public key', function() {
|
describe('verify public key', function() {
|
||||||
it('should verify public key', function(done) {
|
it('should verify public key', function(done) {
|
||||||
var uuid = 'asdfasdfasdfasdf';
|
var uuid = 'asdfasdfasdfasdf';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var LawnchairDAO = require('../../src/js/dao/lawnchair-dao');
|
var LawnchairDAO = require('../../../src/js/service/lawnchair');
|
||||||
|
|
||||||
|
|
||||||
var dbName = 'lawnchair@test.com';
|
var dbName = 'lawnchair@test.com';
|
||||||
@ -20,13 +20,10 @@ var data2 = {
|
|||||||
describe('Lawnchair DAO unit tests', function() {
|
describe('Lawnchair DAO unit tests', function() {
|
||||||
var lawnchairDao;
|
var lawnchairDao;
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function() {
|
||||||
lawnchairDao = new LawnchairDAO();
|
lawnchairDao = new LawnchairDAO();
|
||||||
lawnchairDao.init(dbName, function(err) {
|
lawnchairDao.init(dbName);
|
||||||
expect(err).to.not.exist;
|
|
||||||
expect(lawnchairDao._db).to.exist;
|
expect(lawnchairDao._db).to.exist;
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function(done) {
|
afterEach(function(done) {
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var mocks = angular.mock,
|
var cfg = require('../../../src/js/app-config').config;
|
||||||
cfg = require('../../src/js/app-config').config;
|
|
||||||
require('../../src/js/service/mail-config');
|
|
||||||
|
|
||||||
describe('Mail Config Service unit test', function() {
|
describe('Mail Config Service unit test', function() {
|
||||||
var mailConfig, httpBackend;
|
var mailConfig, httpBackend;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
angular.module('mail-config-test', ['woServices']);
|
angular.module('mail-config-test', ['woServices']);
|
||||||
mocks.module('mail-config-test');
|
angular.mock.module('mail-config-test');
|
||||||
mocks.inject(function($injector, $httpBackend) {
|
angular.mock.inject(function($injector, $httpBackend) {
|
||||||
httpBackend = $httpBackend;
|
httpBackend = $httpBackend;
|
||||||
mailConfig = $injector.get('mailConfig');
|
mailConfig = $injector.get('mailConfig');
|
||||||
});
|
});
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var mocks = angular.mock;
|
|
||||||
require('../../src/js/service/newsletter');
|
|
||||||
|
|
||||||
describe('Newsletter Service unit test', function() {
|
describe('Newsletter Service unit test', function() {
|
||||||
var newsletter;
|
var newsletter;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
angular.module('newsletter-test', ['woServices']);
|
angular.module('newsletter-test', ['woServices']);
|
||||||
mocks.module('newsletter-test');
|
angular.mock.module('newsletter-test');
|
||||||
mocks.inject(function($injector) {
|
angular.mock.inject(function($injector) {
|
||||||
newsletter = $injector.get('newsletter');
|
newsletter = $injector.get('newsletter');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var OAuth = require('../../src/js/util/oauth'),
|
var OAuth = require('../../../src/js/service/oauth'),
|
||||||
RestDAO = require('../../src/js/dao/rest-dao');
|
RestDAO = require('../../../src/js/service/rest');
|
||||||
|
|
||||||
describe('OAuth unit tests', function() {
|
describe('OAuth unit tests', function() {
|
||||||
var oauth, googleApiStub, identityStub, getPlatformInfoStub, removeCachedStub,
|
var oauth, googleApiStub, identityStub, getPlatformInfoStub, removeCachedStub,
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var RestDAO = require('../../src/js/dao/rest-dao'),
|
var RestDAO = require('../../../src/js/service/rest'),
|
||||||
PrivateKeyDAO = require('../../src/js/dao/privatekey-dao');
|
PrivateKeyDAO = require('../../../src/js/service/privatekey'),
|
||||||
|
appConfig = require('../../../src/js/app-config');
|
||||||
|
|
||||||
describe('Private Key DAO unit tests', function() {
|
describe('Private Key DAO unit tests', function() {
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ describe('Private Key DAO unit tests', function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
restDaoStub = sinon.createStubInstance(RestDAO);
|
restDaoStub = sinon.createStubInstance(RestDAO);
|
||||||
privkeyDao = new PrivateKeyDAO(restDaoStub);
|
privkeyDao = new PrivateKeyDAO(restDaoStub, appConfig);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {});
|
afterEach(function() {});
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var RestDAO = require('../../src/js/dao/rest-dao'),
|
var RestDAO = require('../../../src/js/service/rest'),
|
||||||
PublicKeyDAO = require('../../src/js/dao/publickey-dao');
|
PublicKeyDAO = require('../../../src/js/service/publickey'),
|
||||||
|
appConfig = require('../../../src/js/app-config');
|
||||||
|
|
||||||
describe('Public Key DAO unit tests', function() {
|
describe('Public Key DAO unit tests', function() {
|
||||||
|
|
||||||
@ -9,7 +10,7 @@ describe('Public Key DAO unit tests', function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
restDaoStub = sinon.createStubInstance(RestDAO);
|
restDaoStub = sinon.createStubInstance(RestDAO);
|
||||||
pubkeyDao = new PublicKeyDAO(restDaoStub);
|
pubkeyDao = new PublicKeyDAO(restDaoStub, appConfig);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {});
|
afterEach(function() {});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var RestDAO = require('../../src/js/dao/rest-dao');
|
var RestDAO = require('../../../src/js/service/rest');
|
||||||
|
|
||||||
describe('Rest DAO unit tests', function() {
|
describe('Rest DAO unit tests', function() {
|
||||||
|
|
||||||
@ -20,18 +20,12 @@ describe('Rest DAO unit tests', function() {
|
|||||||
xhrMock.restore();
|
xhrMock.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('contructor', function() {
|
describe('setBaseUri', function() {
|
||||||
it('should set default base uri', function() {
|
it('should accept base uri', function() {
|
||||||
restDao = new RestDAO();
|
|
||||||
expect(restDao).to.exist;
|
|
||||||
expect(restDao._baseUri).to.exist;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should accept default base uri', function() {
|
|
||||||
var baseUri = 'http://custom.com';
|
var baseUri = 'http://custom.com';
|
||||||
|
restDao = new RestDAO();
|
||||||
restDao = new RestDAO(baseUri);
|
expect(restDao._baseUri).to.not.exist;
|
||||||
expect(restDao).to.exist;
|
restDao.setBaseUri(baseUri);
|
||||||
expect(restDao._baseUri).to.equal(baseUri);
|
expect(restDao._baseUri).to.equal(baseUri);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user