Merge pull request #140 from colkito/fix/angularjs-test-services

Fix/angularjs test services
This commit is contained in:
Gustavo Maximiliano Cortez 2014-04-23 18:25:55 -03:00
commit 9bd20bb6e7
5 changed files with 36 additions and 12 deletions

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
var copay = window.copay = angular.module('copay',[ var copayApp = window.copayApp = angular.module('copay',[
'ngRoute', 'ngRoute',
'mm.foundation', 'mm.foundation',
'monospaced.qrcode', 'monospaced.qrcode',

View file

@ -3,7 +3,7 @@
angular.module('copay.controllerUtils').factory('controllerUtils', function ($rootScope, $location, Socket) { angular.module('copay.controllerUtils').factory('controllerUtils', function ($rootScope, $location, Socket) {
var root = {}; var root = {};
root.logout = function(scope) { root.logout = function() {
delete $rootScope['wallet']; delete $rootScope['wallet'];
$rootScope.totalBalance = 0; $rootScope.totalBalance = 0;
$location.path('signin'); $location.path('signin');
@ -15,7 +15,6 @@ angular.module('copay.controllerUtils').factory('controllerUtils', function ($ro
root.logout(); root.logout();
} }
root.onErrorDigest = function(scope) { root.onErrorDigest = function(scope) {
root.onError(scope); root.onError(scope);
$rootScope.$digest(); $rootScope.$digest();
@ -31,10 +30,12 @@ angular.module('copay.controllerUtils').factory('controllerUtils', function ($ro
$rootScope.wallet = w; $rootScope.wallet = w;
root.updateBalance(); root.updateBalance();
}); });
w.on('refresh', function() { w.on('refresh', function() {
console.log('[controllerUtils.js] Refreshing'); //TODO console.log('[controllerUtils.js] Refreshing'); //TODO
root.updateBalance(); root.updateBalance();
}); });
w.on('openError', root.onErrorDigest); w.on('openError', root.onErrorDigest);
w.on('close', root.onErrorDigest); w.on('close', root.onErrorDigest);
w.netStart(); w.netStart();

View file

@ -19,6 +19,8 @@ module.exports = function(config) {
'lib/angular/angular.min.js', 'lib/angular/angular.min.js',
'lib/angular-route/angular-route.js', 'lib/angular-route/angular-route.js',
'lib/angular-mocks/angular-mocks.js', 'lib/angular-mocks/angular-mocks.js',
'lib/bitcore.js',
'lib/socket.io.js',
//App-specific Code //App-specific Code
'js/*.js', 'js/*.js',
@ -32,6 +34,9 @@ module.exports = function(config) {
//Mocha stuff //Mocha stuff
'test/mocha.conf.js', 'test/mocha.conf.js',
//Configs
'config.js',
//test files //test files
'test/unit/**/*.js' 'test/unit/**/*.js'
], ],
@ -39,9 +44,7 @@ module.exports = function(config) {
// list of files to exclude // list of files to exclude
exclude: [ exclude: [
'js/copayBundle.js',
'js/models/**/*.js', 'js/models/**/*.js',
'js/init.js'
], ],

View file

@ -6,31 +6,31 @@ describe("Unit: Testing Controllers", function() {
beforeEach(angular.mock.module('copay')); beforeEach(angular.mock.module('copay'));
it('should have a AddressesController controller', function() { it('should have a AddressesController controller', function() {
expect(copay.AddressesController).not.to.equal(null); expect(copayApp.AddressesController).not.to.equal(null);
}); });
it('should have a BackupController controller', function() { it('should have a BackupController controller', function() {
expect(copay.Backupcontroller).not.to.equal(null); expect(copayApp.Backupcontroller).not.to.equal(null);
}); });
it('should have a HeaderController controller', function() { it('should have a HeaderController controller', function() {
expect(copay.HeaderController).not.to.equal(null); expect(copayApp.HeaderController).not.to.equal(null);
}); });
it('should have a SendController controller', function() { it('should have a SendController controller', function() {
expect(copay.SendController).not.to.equal(null); expect(copayApp.SendController).not.to.equal(null);
}); });
it('should have a SetupController controller', function() { it('should have a SetupController controller', function() {
expect(copay.SetupController).not.to.equal(null); expect(copayApp.SetupController).not.to.equal(null);
}); });
it('should have a SigninController controller', function() { it('should have a SigninController controller', function() {
expect(copay.SigninController).not.to.equal(null); expect(copayApp.SigninController).not.to.equal(null);
}); });
it('should have a TransactionsController controller', function() { it('should have a TransactionsController controller', function() {
expect(copay.TransactionsController).not.to.equal(null); expect(copayApp.TransactionsController).not.to.equal(null);
}); });
}); });

View file

@ -3,4 +3,24 @@
// //
describe("Unit: Testing Services", function() { describe("Unit: Testing Services", function() {
beforeEach(angular.mock.module('copay.socket'));
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);
}));
beforeEach(angular.mock.module('copay.controllerUtils'));
it('should contain a controllerUtils service', inject(function(controllerUtils) {
expect(controllerUtils).not.to.equal(null);
}));
}); });