refactor(ngModelSpec): use valueFn over curry
Refactor ngModelSpec to use internal helper function `valueFn`. Use instead of multiple-defining a function called `curry`. PR (#15231) Addresses a quick change mentioned in PR 15208 from Issue #14734
This commit is contained in:
@@ -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);
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user