From dbdd3c3500f071609d187be2466dfc865fc56080 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Wed, 4 Jun 2014 11:24:49 -0300 Subject: [PATCH] Refactory ControllerSpect for test is now more clear. A simple test for transactions. --- test/unit/controllers/controllersSpec.js | 80 +++++++++++------------- 1 file changed, 36 insertions(+), 44 deletions(-) diff --git a/test/unit/controllers/controllersSpec.js b/test/unit/controllers/controllersSpec.js index 75d45e881..f437c1ed8 100644 --- a/test/unit/controllers/controllersSpec.js +++ b/test/unit/controllers/controllersSpec.js @@ -3,59 +3,51 @@ // describe("Unit: Testing Controllers", function() { - beforeEach(module('notifications')); - beforeEach(module('copayApp.services')); - beforeEach(module('copayApp.controllers')); + var scope; - var scope, addressCtrl; -// + beforeEach(module('notifications')); + beforeEach(module('copayApp.services')); + beforeEach(module('copayApp.controllers')); + + describe('Address Controller', function() { + var addressCtrl; beforeEach(inject(function($controller, $rootScope) { scope = $rootScope.$new(); addressCtrl = $controller('AddressesController', { $scope: scope, }); })); - + it('should have a AddressesController controller', function() { + expect(scope.loading).equal(false); + }); - it('should have a AddressesController controller', function() { - 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('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; -// })); + describe('Transactions Controller', function() { + var transactionCtrl; + beforeEach(inject(function($controller, $rootScope) { + scope = $rootScope.$new(); + transactionsCtrl = $controller('TransactionsController', { + $scope: scope, + }); + })); + + it('should have a TransactionController controller', function() { + expect(scope.loading).equal(false); + }); + + it('should return an empty array of tx', function() { + scope.getTransactions(); + expect(scope.blockchain_txs).to.be.empty; + console.log('asdfasdf', scope.blockchain_txs); + }); + + }); });