Merge pull request #759 from cmgustavo/bug/01-amount-input

Bug/01 amount input
This commit is contained in:
Matias Alejo Garcia 2014-06-26 22:47:56 -03:00
commit 4467ae270f
7 changed files with 136 additions and 44 deletions

View file

@ -282,10 +282,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(
'<form name="form">' +
'<input type="number" id="amount" name="amount" placeholder="Amount" ng-model="amount" min="0.0001" max="10000000" enough-amount required>' +
'</form>'
);
scope.model = {
amount: null
};
$compile(element)(scope);
scope.$digest();
form = scope.form;
sendCtrl = $controller('SendController', {
$scope: scope,
$modal: {},
@ -296,8 +309,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);
});
});