Skip to content

Commit

Permalink
refactor(ngModelSpec): use valueFn over curry
Browse files Browse the repository at this point in the history
Refactor ngModelSpec to use internal helper function `valueFn`.
Use instead of multiple-defining a function called `curry`.

PR (angular#15231)

Addresses a quick change mentioned in PR 15208 from Issue angular#14734
  • Loading branch information
BobChao87 authored and Narretz committed Oct 9, 2016
1 parent 39a3b58 commit faf0c3e
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions test/ng/directive/ngModelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -827,21 +827,15 @@ describe('ngModel', function() {


it('should only validate to true if all validations are true', function() {
var curry = function(v) {
return function() {
return v;
};
};

ctrl.$modelValue = undefined;
ctrl.$validators.a = curry(true);
ctrl.$validators.b = curry(true);
ctrl.$validators.c = curry(false);
ctrl.$validators.a = valueFn(true);
ctrl.$validators.b = valueFn(true);
ctrl.$validators.c = valueFn(false);

ctrl.$validate();
expect(ctrl.$valid).toBe(false);

ctrl.$validators.c = curry(true);
ctrl.$validators.c = valueFn(true);

ctrl.$validate();
expect(ctrl.$valid).toBe(true);
Expand Down Expand Up @@ -875,16 +869,10 @@ describe('ngModel', function() {


it('should register invalid validations on the $error object', function() {
var curry = function(v) {
return function() {
return v;
};
};

ctrl.$modelValue = undefined;
ctrl.$validators.unique = curry(false);
ctrl.$validators.tooLong = curry(false);
ctrl.$validators.notNumeric = curry(true);
ctrl.$validators.unique = valueFn(false);
ctrl.$validators.tooLong = valueFn(false);
ctrl.$validators.notNumeric = valueFn(true);

ctrl.$validate();

Expand Down

0 comments on commit faf0c3e

Please sign in to comment.