diff --git a/js/controllers/send.js b/js/controllers/send.js index 7989d1ac7..ad3e861b5 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -492,7 +492,7 @@ angular.module('copayApp.controllers').controller('SendController', return $scope.setFromPayPro(parsed.data.merchant); var amount = (parsed.data && parsed.data.amount) ? - ((parsed.data.amount * 100000000).toFixed(0) * satToUnit).toFixed(w.settings.unitDecimals): 0; + ((parsed.data.amount * 100000000).toFixed(0) * satToUnit).toFixed(w.settings.unitDecimals) : 0; $scope.setForm(addr, amount, parsed.data.message, true); return addr; diff --git a/test/unit/controllers/controllersSpec.js b/test/unit/controllers/controllersSpec.js index f544910c3..441b7b9a2 100644 --- a/test/unit/controllers/controllersSpec.js +++ b/test/unit/controllers/controllersSpec.js @@ -106,6 +106,7 @@ describe("Unit: Controllers", function() { isChange: false }]); + var iden = {}; iden.getLastFocusedWallet = sinon.stub().returns(null); iden.getWallets = sinon.stub().returns([w]); @@ -140,12 +141,37 @@ describe("Unit: Controllers", function() { scope.create(invalidForm); }); }); + }); + + + describe('Create Profile Controller', function() { + var c; + beforeEach(inject(function($controller, $rootScope) { + scope = $rootScope.$new(); + c = $controller('CreateProfileController', { + $scope: scope, + }); + })); + + it('should exist', function() { + should.exist(c); + }); + + it('#init', function() { + scope.init(); + }); + + it('#clear', function() { + scope.clear(); + }); }); describe('Receive Controller', function() { var c; + var rootScope; beforeEach(inject(function($controller, $rootScope) { + rootScope = $rootScope; scope = $rootScope.$new(); c = $controller('ReceiveController', { $scope: scope, @@ -204,6 +230,8 @@ describe("Unit: Controllers", function() { c.networkName = walletConfig.networkName; c.version = '0.0.1'; + c.generateAddress = sinon.stub().returns({}); + c.balanceInfo = {}; return new Wallet(c); @@ -217,6 +245,11 @@ describe("Unit: Controllers", function() { should.exist(c); }); + it('#init', function() { + scope.init(); + rootScope.title.should.be.equal('Receive'); + }); + it('should call setAddressList', function() { scope.setAddressList(); expect(scope.addresses).to.be.empty; @@ -224,6 +257,12 @@ describe("Unit: Controllers", function() { scope.setAddressList(); expect(scope.addresses).to.be.empty; }); + + it('#newAddr', function() { + rootScope.wallet.generateAddress = sinon.stub().returns({}); + scope.newAddr(); + rootScope.wallet.generateAddress.calledOnce.should.be.true; + }); }); describe('History Controller', function() { @@ -254,9 +293,10 @@ describe("Unit: Controllers", function() { }); describe('Send Controller', function() { - var scope, form, sendForm, sendCtrl; + var scope, form, sendForm, sendCtrl, rootScope; beforeEach(angular.mock.inject(function($compile, $rootScope, $controller, rateService, notification) { scope = $rootScope.$new(); + rootScope = $rootScope; scope.rateService = rateService; var element = angular.element( '