From e330da0b9b651b78e23e999c45a1a356d86d0c34 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Wed, 25 Jun 2014 19:11:50 -0300 Subject: [PATCH] Fixed test and new test entry for new method --- test/unit/controllers/controllersSpec.js | 26 +++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/test/unit/controllers/controllersSpec.js b/test/unit/controllers/controllersSpec.js index 5c8dd6ed8..03de6ccf6 100644 --- a/test/unit/controllers/controllersSpec.js +++ b/test/unit/controllers/controllersSpec.js @@ -283,10 +283,23 @@ describe("Unit: Controllers", function() { }); describe('Send Controller', function() { - var sendCtrl; - beforeEach(inject(function($controller, $rootScope) { + var sendCtrl, form; + beforeEach(inject(function($compile, $rootScope, $controller) { scope = $rootScope.$new(); $rootScope.availableBalance = 123456; + + var element = angular.element( + '
' + + '' + + '
' + ); + scope.model = { + amount: null + }; + $compile(element)(scope); + scope.$digest(); + form = scope.form; + sendCtrl = $controller('SendController', { $scope: scope, $modal: {}, @@ -297,8 +310,15 @@ describe("Unit: Controllers", function() { expect(scope.isMobile).not.to.equal(null); }); it('should autotop balance correctly', function() { - scope.topAmount(); + scope.topAmount(form); + form.amount.$setViewValue(123356); expect(scope.amount).to.equal(123356); + expect(form.amount.$invalid).to.equal(false); + expect(form.amount.$pristine).to.equal(false); + }); + it('should return available amount', function() { + var amount = scope.getAvailableAmount(); + expect(amount).to.equal(123356); }); });