diff --git a/js/app.js b/js/app.js index ce3c7e391..2060979fc 100644 --- a/js/app.js +++ b/js/app.js @@ -26,37 +26,13 @@ var copayApp = window.copayApp = angular.module('copayApp',[ 'monospaced.qrcode', 'notifications', 'copayApp.filters', - 'copayApp.header', - 'copayApp.footer', - 'copayApp.addresses', - 'copayApp.transactions', - 'copayApp.send', - 'copayApp.backup', - 'copayApp.walletFactory', - 'copayApp.signin', - 'copayApp.socket', - 'copayApp.controllerUtils', - 'copayApp.setup', + 'copayApp.controllers', 'copayApp.directives', - 'copayApp.video', - 'copayApp.import', - 'copayApp.passphrase', - 'copayApp.settings' + 'copayApp.services', ]); -angular.module('copayApp.header', []); -angular.module('copayApp.footer', []); -angular.module('copayApp.addresses', []); -angular.module('copayApp.transactions', []); -angular.module('copayApp.send', []); -angular.module('copayApp.backup', []); -angular.module('copayApp.walletFactory', []); -angular.module('copayApp.controllerUtils', []); -angular.module('copayApp.signin', []); -angular.module('copayApp.setup', []); -angular.module('copayApp.socket', []); +angular.module('copayApp.filters', []); +angular.module('copayApp.controllers', []); angular.module('copayApp.directives', []); -angular.module('copayApp.video', []); -angular.module('copayApp.import', []); -angular.module('copayApp.passphrase', []); -angular.module('copayApp.settings', []); +angular.module('copayApp.services', []); + diff --git a/js/controllers/addresses.js b/js/controllers/addresses.js index a1884cab1..8e9e0a213 100644 --- a/js/controllers/addresses.js +++ b/js/controllers/addresses.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.addresses').controller('AddressesController', +angular.module('copayApp.controllers').controller('AddressesController', function($scope, $rootScope, $timeout, controllerUtils) { $scope.loading = false; var w = $rootScope.wallet; diff --git a/js/controllers/backup.js b/js/controllers/backup.js index e48836277..f23a44f5d 100644 --- a/js/controllers/backup.js +++ b/js/controllers/backup.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.backup').controller('BackupController', +angular.module('copayApp.controllers').controller('BackupController', function($scope, $rootScope, $location, $window, $timeout, $modal) { $scope.title = 'Backup'; diff --git a/js/controllers/footer.js b/js/controllers/footer.js index 82fe4762b..280fff354 100644 --- a/js/controllers/footer.js +++ b/js/controllers/footer.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.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; diff --git a/js/controllers/header.js b/js/controllers/header.js index cdec7c5c4..c33362952 100644 --- a/js/controllers/header.js +++ b/js/controllers/header.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.header').controller('HeaderController', +angular.module('copayApp.controllers').controller('HeaderController', function($scope, $rootScope, $location, $notification, $http, walletFactory, controllerUtils) { $scope.menu = [ { diff --git a/js/controllers/import.js b/js/controllers/import.js index b65fc655c..f58d261bb 100644 --- a/js/controllers/import.js +++ b/js/controllers/import.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.import').controller('ImportController', +angular.module('copayApp.controllers').controller('ImportController', function($scope, $rootScope, walletFactory, controllerUtils, Passphrase) { $scope.title = 'Import a backup'; var reader = new FileReader(); diff --git a/js/controllers/send.js b/js/controllers/send.js index ff8e9b369..9bb5d7700 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.send').controller('SendController', +angular.module('copayApp.controllers').controller('SendController', function($scope, $rootScope, $window, $location, $timeout) { $scope.title = 'Send'; $scope.loading = false; diff --git a/js/controllers/settings.js b/js/controllers/settings.js index facceb343..4c1bb13c1 100644 --- a/js/controllers/settings.js +++ b/js/controllers/settings.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.settings').controller('SettingsController', +angular.module('copayApp.controllers').controller('SettingsController', function($scope, $rootScope, $window, $location) { $scope.title = 'Settings'; diff --git a/js/controllers/setup.js b/js/controllers/setup.js index 6523c2daa..4f49dcb96 100644 --- a/js/controllers/setup.js +++ b/js/controllers/setup.js @@ -32,7 +32,7 @@ var valid_pairs = { '1,12': 489 }; -angular.module('copayApp.setup').controller('SetupController', +angular.module('copayApp.controllers').controller('SetupController', function($scope, $rootScope, $location, $timeout, walletFactory, controllerUtils, Passphrase) { $rootScope.videoInfo = {}; diff --git a/js/controllers/signin.js b/js/controllers/signin.js index 42e73446a..506c42512 100644 --- a/js/controllers/signin.js +++ b/js/controllers/signin.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.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(); diff --git a/js/controllers/transactions.js b/js/controllers/transactions.js index 3f47ffae1..3613012c4 100644 --- a/js/controllers/transactions.js +++ b/js/controllers/transactions.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.transactions').controller('TransactionsController', +angular.module('copayApp.controllers').controller('TransactionsController', function($scope, $rootScope, $timeout, controllerUtils) { $scope.title = 'Transactions'; diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index b2b4f8579..3581fa682 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllerUtils') +angular.module('copayApp.services') .factory('controllerUtils', function($rootScope, $sce, $location, $notification, Socket, video) { var root = {}; var bitcore = require('bitcore'); diff --git a/js/services/passphrase.js b/js/services/passphrase.js index fb8196321..00ff9e2be 100644 --- a/js/services/passphrase.js +++ b/js/services/passphrase.js @@ -1,3 +1,4 @@ 'use strict'; -angular.module('copayApp.passphrase').value('Passphrase', new copay.Passphrase(config.passphrase)); +angular.module('copayApp.services') + .value('Passphrase', new copay.Passphrase(config.passphrase)); diff --git a/js/services/socket.js b/js/services/socket.js index 7b3c4713f..1642309c2 100644 --- a/js/services/socket.js +++ b/js/services/socket.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.socket').factory('Socket', +angular.module('copayApp.services').factory('Socket', function($rootScope) { var listeners = []; var url = 'http://' + config.socket.host + ':' + config.socket.port; diff --git a/js/services/video.js b/js/services/video.js index 9f4fb8523..af2073589 100644 --- a/js/services/video.js +++ b/js/services/video.js @@ -93,4 +93,4 @@ Video.prototype.close = function() { this.mediaConnections = {}; }; -angular.module('copayApp.video').value('video', new Video()); +angular.module('copayApp.services').value('video', new Video()); diff --git a/js/services/walletFactory.js b/js/services/walletFactory.js index ba2497425..3e201b6f1 100644 --- a/js/services/walletFactory.js +++ b/js/services/walletFactory.js @@ -1,4 +1,4 @@ 'use strict'; -angular.module('copayApp.walletFactory').value('walletFactory', new copay.WalletFactory(config, copay.version)); +angular.module('copayApp.services').value('walletFactory', new copay.WalletFactory(config, copay.version)); diff --git a/karma.conf.js b/karma.conf.js index 63e9fb1e0..8331b8672 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -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' ], diff --git a/test/unit/controllers/controllersSpec.js b/test/unit/controllers/controllersSpec.js index 904c31377..75d45e881 100644 --- a/test/unit/controllers/controllersSpec.js +++ b/test/unit/controllers/controllersSpec.js @@ -3,13 +3,31 @@ // describe("Unit: Testing Controllers", function() { -// beforeEach(module('copay')); - beforeEach(module('copay.signin')); - + beforeEach(module('notifications')); + beforeEach(module('copayApp.services')); + beforeEach(module('copayApp.controllers')); + + var scope, addressCtrl; +// + beforeEach(inject(function($controller, $rootScope) { + scope = $rootScope.$new(); + addressCtrl = $controller('AddressesController', { + $scope: scope, + }); + })); + + + it('should have a AddressesController controller', function() { -console.log('[controllersSpec.js.10:copayApp:]',copayApp.controller); //TODO - expect(copayApp.AddressesController).not.to.equal(null); + expect(scope.loading).equal(false); }); + + 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); diff --git a/test/unit/directives/directivesSpec.js b/test/unit/directives/directivesSpec.js index 42aa5f521..4f3b76d82 100644 --- a/test/unit/directives/directivesSpec.js +++ b/test/unit/directives/directivesSpec.js @@ -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) { diff --git a/test/unit/services/servicesSpec.js b/test/unit/services/servicesSpec.js index fd3563eee..fbb8f6c2d 100644 --- a/test/unit/services/servicesSpec.js +++ b/test/unit/services/servicesSpec.js @@ -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);