Merge pull request #540 from matiu/feature/UXtesting

Feature/u xtesting
This commit is contained in:
Gustavo Maximiliano Cortez 2014-06-03 18:22:58 -03:00
commit 5e3b1e94e2
25 changed files with 98 additions and 96 deletions

View File

@ -16,46 +16,23 @@ var log = function() {
if (config.verbose) console.log(arguments);
}
// From the bundle
var copay = require('copay');
var copayApp = window.copayApp = angular.module('copay',[
var copayApp = window.copayApp = angular.module('copayApp',[
'ngRoute',
'angularMoment',
'mm.foundation',
'monospaced.qrcode',
'notifications',
'copay.filters',
'copay.header',
'copay.footer',
'copay.addresses',
'copay.transactions',
'copay.send',
'copay.backup',
'copay.walletFactory',
'copay.signin',
'copay.socket',
'copay.controllerUtils',
'copay.setup',
'copay.directives',
'copay.video',
'copay.import',
'copay.passphrase',
'copay.settings'
'copayApp.filters',
'copayApp.controllers',
'copayApp.directives',
'copayApp.services',
]);
angular.module('copay.header', []);
angular.module('copay.footer', []);
angular.module('copay.addresses', []);
angular.module('copay.transactions', []);
angular.module('copay.send', []);
angular.module('copay.backup', []);
angular.module('copay.walletFactory', []);
angular.module('copay.controllerUtils', []);
angular.module('copay.signin', []);
angular.module('copay.setup', []);
angular.module('copay.socket', []);
angular.module('copay.directives', []);
angular.module('copay.video', []);
angular.module('copay.import', []);
angular.module('copay.passphrase', []);
angular.module('copay.settings', []);
angular.module('copayApp.filters', []);
angular.module('copayApp.controllers', []);
angular.module('copayApp.directives', []);
angular.module('copayApp.services', []);

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copay.addresses').controller('AddressesController',
angular.module('copayApp.controllers').controller('AddressesController',
function($scope, $rootScope, $timeout, controllerUtils) {
$scope.loading = false;
var w = $rootScope.wallet;

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copay.backup').controller('BackupController',
angular.module('copayApp.controllers').controller('BackupController',
function($scope, $rootScope, $location, $window, $timeout, $modal) {
$scope.title = 'Backup';

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copay.footer').controller('FooterController', function($rootScope, $sce, $scope, $http) {
angular.module('copayApp.controllers').controller('FooterController', function($rootScope, $sce, $scope, $http) {
if (config.themes && Array.isArray(config.themes) && config.themes[0]) {
$scope.themes = config.themes;

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copay.header').controller('HeaderController',
angular.module('copayApp.controllers').controller('HeaderController',
function($scope, $rootScope, $location, $notification, $http, walletFactory, controllerUtils) {
$scope.menu = [
{

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copay.import').controller('ImportController',
angular.module('copayApp.controllers').controller('ImportController',
function($scope, $rootScope, walletFactory, controllerUtils, Passphrase) {
$scope.title = 'Import a backup';
var reader = new FileReader();

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copay.send').controller('SendController',
angular.module('copayApp.controllers').controller('SendController',
function($scope, $rootScope, $window, $location, $timeout) {
$scope.title = 'Send';
$scope.loading = false;

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copay.settings').controller('SettingsController',
angular.module('copayApp.controllers').controller('SettingsController',
function($scope, $rootScope, $window, $location) {
$scope.title = 'Settings';

View File

@ -32,7 +32,7 @@ var valid_pairs = {
'1,12': 489
};
angular.module('copay.setup').controller('SetupController',
angular.module('copayApp.controllers').controller('SetupController',
function($scope, $rootScope, $location, $timeout, walletFactory, controllerUtils, Passphrase) {
$rootScope.videoInfo = {};

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copay.signin').controller('SigninController',
angular.module('copayApp.controllers').controller('SigninController',
function($scope, $rootScope, $location, walletFactory, controllerUtils, Passphrase) {
var cmp = function(o1, o2){
var v1 = o1.show.toLowerCase(), v2 = o2.show.toLowerCase();
@ -24,10 +24,16 @@ angular.module('copay.signin').controller('SigninController',
console.log('## Obtaining passphrase...');
Passphrase.getBase64Async(password, function(passphrase){
console.log('## Passphrase obtained');
var w = walletFactory.open($scope.selectedWalletId, { passphrase: passphrase});
var w, errMsg;
try{
var w = walletFactory.open($scope.selectedWalletId, { passphrase: passphrase});
} catch (e){
errMsg = e.message;
};
if (!w) {
$scope.loading = $scope.failure = false;
$rootScope.$flashMessage = { message: 'Wrong password', type: 'error'};
$rootScope.$flashMessage = { message: errMsg || 'Wrong password', type: 'error'};
$rootScope.$digest();
return;
}

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copay.transactions').controller('TransactionsController',
angular.module('copayApp.controllers').controller('TransactionsController',
function($scope, $rootScope, $timeout, controllerUtils) {
$scope.title = 'Transactions';

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copay.directives')
angular.module('copayApp.directives')
.directive('validAddress', [
function() {

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copay.filters', [])
angular.module('copayApp.filters', [])
.filter('amTimeAgo', ['amMoment', function(amMoment) {
return function(input) {
return amMoment.preprocessDate(input).fromNow();

View File

@ -2,5 +2,5 @@
angular.element(document).ready(function() {
// Init the app
angular.bootstrap(document, ['copay']);
angular.bootstrap(document, ['copayApp']);
});

View File

@ -65,7 +65,6 @@ Wallet.prototype.seedCopayer = function(pubKey) {
Wallet.prototype.connectToAll = function() {
var all = this.publicKeyRing.getAllCopayerIds();
console.log('[Wallet.js.58] connecting'); //TODO
this.network.connectToCopayers(all);
if (this.seededCopayerId) {
this.sendWalletReady(this.seededCopayerId);

View File

@ -2,7 +2,7 @@
//Setting up route
angular
.module('copay')
.module('copayApp')
.config(function($routeProvider) {
$routeProvider
@ -56,7 +56,7 @@ angular
//Setting HTML5 Location Mode
angular
.module('copay')
.module('copayApp')
.config(function($locationProvider) {
$locationProvider
.html5Mode(false);

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copay.controllerUtils')
angular.module('copayApp.services')
.factory('controllerUtils', function($rootScope, $sce, $location, $notification, Socket, video) {
var root = {};
var bitcore = require('bitcore');

View File

@ -1,3 +1,4 @@
'use strict';
angular.module('copay.passphrase').value('Passphrase', new copay.Passphrase(config.passphrase));
angular.module('copayApp.services')
.value('Passphrase', new copay.Passphrase(config.passphrase));

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copay.socket').factory('Socket',
angular.module('copayApp.services').factory('Socket',
function($rootScope) {
var listeners = [];
var url = 'http://' + config.socket.host + ':' + config.socket.port;

View File

@ -93,4 +93,4 @@ Video.prototype.close = function() {
this.mediaConnections = {};
};
angular.module('copay.video').value('video', new Video());
angular.module('copayApp.services').value('video', new Video());

View File

@ -1,4 +1,4 @@
'use strict';
angular.module('copay.walletFactory').value('walletFactory', new copay.WalletFactory(config, copay.version));
angular.module('copayApp.services').value('walletFactory', new copay.WalletFactory(config, copay.version));

View File

@ -47,8 +47,6 @@ module.exports = function(config) {
//Mocha stuff
'test/mocha.conf.js',
//test files
'test/unit/**/*.js',
//App-specific Code
'js/app.js',
@ -57,7 +55,11 @@ module.exports = function(config) {
'js/filters.js',
'js/services/*.js',
'js/controllers/*.js',
'js/init.js'
'js/init.js',
//test files
'test/unit/**/*.js'
],

View File

@ -3,39 +3,59 @@
//
describe("Unit: Testing Controllers", function() {
beforeEach(angular.mock.module('copay'));
beforeEach(module('notifications'));
beforeEach(module('copayApp.services'));
beforeEach(module('copayApp.controllers'));
it('should have a AddressesController controller', function() {
expect(copayApp.AddressesController).not.to.equal(null);
});
var scope, addressCtrl;
//
beforeEach(inject(function($controller, $rootScope) {
scope = $rootScope.$new();
addressCtrl = $controller('AddressesController', {
$scope: scope,
});
}));
it('should have a BackupController controller', function() {
expect(copayApp.Backupcontroller).not.to.equal(null);
});
it('should have a HeaderController controller', function() {
expect(copayApp.HeaderController).not.to.equal(null);
});
it('should have a AddressesController controller', function() {
expect(scope.loading).equal(false);
});
it('should have a SendController controller', function() {
expect(copayApp.SendController).not.to.equal(null);
});
it('should have a SetupController controller', function() {
expect(copayApp.SetupController).not.to.equal(null);
});
it('should have a SigninController controller', function() {
expect(copayApp.SigninController).not.to.equal(null);
});
it('should have a TransactionsController controller', function() {
expect(copayApp.TransactionsController).not.to.equal(null);
});
beforeEach(angular.mock.module('copay.walletFactory'));
it('should display a link to create a new wallet if no wallets in localStorage', inject(function(walletFactory) {
expect(walletFactory.storage.getWalletIds()).to.be.empty;
}));
it('selectedAddr should modify scope', function() {
expect(scope.selectedAddress).equal(undefined);
scope.selectAddress('hola');
expect(scope.selectedAddr).equal('hola');
});
//
// it('should have a BackupController controller', function() {
// expect(copayApp.Backupcontroller).not.to.equal(null);
// });
//
// it('should have a HeaderController controller', function() {
// expect(copayApp.HeaderController).not.to.equal(null);
// });
//
// it('should have a SendController controller', function() {
// expect(copayApp.SendController).not.to.equal(null);
// });
//
// it('should have a SetupController controller', function() {
// expect(copayApp.SetupController).not.to.equal(null);
// });
//
// it('should have a SigninController controller', function() {
// expect(copayApp.SigninController).not.to.equal(null);
// console.log('[controllersSpec.js.30:copayApp:]',copayApp); //TODO
// });
//
// it('should have a TransactionsController controller', function() {
// expect(copayApp.TransactionsController).not.to.equal(null);
// });
//
// beforeEach(angular.mock.module('copay.walletFactory'));
// it('should display a link to create a new wallet if no wallets in localStorage', inject(function(walletFactory) {
// expect(walletFactory.storage.getWalletIds()).to.be.empty;
// }));
});

View File

@ -6,7 +6,7 @@ describe("Unit: Testing Directives", function() {
var $scope, form;
beforeEach(module('copay.directives'));
beforeEach(module('copayApp.directives'));
describe('Validate Address', function() {
beforeEach(inject(function($compile, $rootScope) {

View File

@ -3,22 +3,19 @@
//
describe("Unit: Testing Services", function() {
beforeEach(angular.mock.module('copay.socket'));
beforeEach(angular.mock.module('copayApp.services'));
it('should contain a Socket service', inject(function(Socket) {
expect(Socket).not.to.equal(null);
}));
beforeEach(angular.mock.module('copay.walletFactory'));
it('should contain a walletFactory service', inject(function(walletFactory) {
expect(walletFactory).not.to.equal(null);
}));
// TODO
/*beforeEach(angular.mock.module('copay.controllerUtils'));
/*beforeEach(angular.mock.module('copayApp.controllerUtils'));
it('should contain a controllerUtils service', inject(function(controllerUtils) {
expect(controllerUtils).not.to.equal(null);