Skip to content
Permalink
Browse files

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
  • Loading branch information
BobChao87 authored and Narretz committed Oct 9, 2016
1 parent 1b91d30 commit fcffa0d138acc7041ea66af2933cbc23264373e1
Showing with 7 additions and 19 deletions.
  1. +7 −19 test/ng/directive/ngModelSpec.js
@@ -827,38 +827,26 @@ 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);
});


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();

0 comments on commit fcffa0d

Please sign in to comment.
You can’t perform that action at this time.