From 462c5e2854096013f06c507e27f7f10ffe04f925 Mon Sep 17 00:00:00 2001 From: Ben Wiklund Date: Tue, 7 Jan 2014 20:54:36 -0800 Subject: [PATCH] test(input): failing min/max databinding test observing min/maxlength attributes --- src/ng/directive/input.js | 4 ++-- test/ng/directive/inputSpec.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 4e77397878dd..55299e8357b3 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -509,8 +509,8 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) { // min length validator if (attr.ngMinlength) { - var minlength = int(attr.ngMinlength); var minLengthValidator = function(value) { + var minlength = int(attr.ngMinlength); return validate(ctrl, 'minlength', ctrl.$isEmpty(value) || value.length >= minlength, value); }; @@ -520,8 +520,8 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) { // max length validator if (attr.ngMaxlength) { - var maxlength = int(attr.ngMaxlength); var maxLengthValidator = function(value) { + var maxlength = int(attr.ngMaxlength); return validate(ctrl, 'maxlength', ctrl.$isEmpty(value) || value.length <= maxlength, value); }; diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js index 26abceae1cfe..7b2cfd9ce049 100644 --- a/test/ng/directive/inputSpec.js +++ b/test/ng/directive/inputSpec.js @@ -733,6 +733,21 @@ describe('input', function() { changeInputValueTo('aaa'); expect(scope.value).toBe('aaa'); }); + + + it('should be updatable via binding', function(){ + scope.boundLength = 3; + compileInput(''); + + changeInputValueTo('aaaa'); + expect(scope.value).toBe('aaaa'); + + scope.boundLength = 6; + scope.$digest(); + changeInputValueTo('aabb'); // TODO: this shouldn't need to changed to invalidate, but is (?) + + expect(scope.value).toBeUndefined(); + }); }); @@ -747,6 +762,20 @@ describe('input', function() { changeInputValueTo('aaa'); expect(scope.value).toBe('aaa'); }); + + + it('should be updatable via binding', function(){ + scope.boundLength = 6; + compileInput(''); + + changeInputValueTo('aaaa'); + expect(scope.value).toBe('aaaa'); + + scope.boundLength = 3; + scope.$digest(); + changeInputValueTo('aaab'); // TODO: this shouldn't need to changed to invalidate, but is (?) + expect(scope.value).toBeUndefined(); + }); });