Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit faf0c3e

Browse files
BobChao87Narretz
authored andcommitted
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
1 parent 39a3b58 commit faf0c3e

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

test/ng/directive/ngModelSpec.js

+7-19
Original file line numberDiff line numberDiff line change
@@ -827,21 +827,15 @@ describe('ngModel', function() {
827827

828828

829829
it('should only validate to true if all validations are true', function() {
830-
var curry = function(v) {
831-
return function() {
832-
return v;
833-
};
834-
};
835-
836830
ctrl.$modelValue = undefined;
837-
ctrl.$validators.a = curry(true);
838-
ctrl.$validators.b = curry(true);
839-
ctrl.$validators.c = curry(false);
831+
ctrl.$validators.a = valueFn(true);
832+
ctrl.$validators.b = valueFn(true);
833+
ctrl.$validators.c = valueFn(false);
840834

841835
ctrl.$validate();
842836
expect(ctrl.$valid).toBe(false);
843837

844-
ctrl.$validators.c = curry(true);
838+
ctrl.$validators.c = valueFn(true);
845839

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

876870

877871
it('should register invalid validations on the $error object', function() {
878-
var curry = function(v) {
879-
return function() {
880-
return v;
881-
};
882-
};
883-
884872
ctrl.$modelValue = undefined;
885-
ctrl.$validators.unique = curry(false);
886-
ctrl.$validators.tooLong = curry(false);
887-
ctrl.$validators.notNumeric = curry(true);
873+
ctrl.$validators.unique = valueFn(false);
874+
ctrl.$validators.tooLong = valueFn(false);
875+
ctrl.$validators.notNumeric = valueFn(true);
888876

889877
ctrl.$validate();
890878

0 commit comments

Comments
 (0)