Skip to content

Commit

Permalink
Correção de bug quanto o valor para validação era do tipo string
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernardo Loureiro committed May 13, 2015
1 parent 3813664 commit 844522f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/scripts/angular-boleto.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ angular.module('angular.boleto', ['ui.mask'])
if (typeof scope.validarValor !== 'undefined') {
var valor = numeroBoleto.substr(37, 10);
valor = parseFloat(valor.substr(0, 8) + '.' + valor.substr(valor.length-2));
if (valor !== scope.validarValor) {
if (valor !== parseFloat(scope.validarValor)) {
scope.form[scope.name].$setValidity('valorErrado', false);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/angular-boleto.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-boleto",
"version": "0.1.4",
"version": "0.1.5",
"homepage": "https://github.com/bernardolm/angular-boleto",
"authors": [
"Bernardo Loureiro <bernardo.lou@gmail.com> (http://bernardoloureiro.com.br)"
Expand Down
1 change: 1 addition & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = function(config) {
files: bowerDependencies.js.concat([
'app/scripts/app.js',
'app/scripts/*.*',
'!app/**/*.min.js',
'test/*Spec.js'
]),

Expand Down
10 changes: 10 additions & 0 deletions test/boletoSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,16 @@ describe('Campo de boleto bancário', function () {
expect($scope.form1.boleto.$error.vencimentoErrado).toBe(false);
});

it ('deverá estar válido com código de boleto com valor correto', function () {
$rootScope.valor = "1274567.89";
$scope.form1.boleto.$setViewValue('21890010070014560208200371313180100000127456789');
$scope.$digest();

expect($scope.form1.$valid).toBe(true);
expect($scope.form1.boleto.$valid).toBe(true);
expect($scope.form1.boleto.$error.valorErrado).toBe(false);
});

/*** Testes para datas acima do limite da FEBRABAN
it ('deverá estar válido com código de boleto com vencimento correto', function () {
$rootScope.vencimento = '2052-07-09';
Expand Down

0 comments on commit 844522f

Please sign in to comment.