@@ -47,6 +47,17 @@ describe('uiValidate', function () {
47
47
expect ( scope . form . input . $valid ) . toBeFalsy ( ) ;
48
48
expect ( scope . form . input . $error ) . toEqual ( { validator : true } ) ;
49
49
} ) ) ;
50
+
51
+ it ( 'should keep the invalid value in model if it is marked as invalid' , inject ( function ( ) {
52
+
53
+ var testValue = 'test123' ;
54
+ scope . value = testValue ;
55
+ scope . validate = falseValidator ;
56
+ var inputElm = compileAndDigest ( '<input name="input" ng-model="value" ui-validate="\'validate($value)\'">' , scope ) ;
57
+ expect ( scope . form . input . $valid ) . toBeFalsy ( ) ;
58
+ expect ( scope . value ) . toEqual ( testValue ) ;
59
+ expect ( inputElm . val ( ) ) . toEqual ( testValue ) ;
60
+ } ) ) ;
50
61
} ) ;
51
62
52
63
describe ( 'validation on model change' , function ( ) {
@@ -96,6 +107,19 @@ describe('uiValidate', function () {
96
107
expect ( scope . form . input . $error . key1 ) . toBeFalsy ( ) ;
97
108
expect ( scope . form . input . $error . key2 ) . toBeTruthy ( ) ;
98
109
} ) ;
110
+
111
+ it ( 'should show subsequent validation errors as false if the first of multiple validators fails, but the other validations do not fail' , function ( ) {
112
+
113
+ scope . validate1 = falseValidator ;
114
+ scope . validate2 = trueValidator ;
115
+ scope . validate3 = trueValidator ;
116
+
117
+ compileAndDigest ( '<input name="input" ng-model="value" ui-validate="{key1 : \'validate1($value)\', key2 : \'validate2($value)\', key3 : \'validate2($value)\'}">' , scope ) ;
118
+ expect ( scope . form . input . $valid ) . toBeFalsy ( ) ;
119
+ expect ( scope . form . input . $error . key1 ) . toBeTruthy ( ) ;
120
+ expect ( scope . form . input . $error . key2 ) . toBeFalsy ( ) ;
121
+ expect ( scope . form . input . $error . key3 ) . toBeFalsy ( ) ;
122
+ } ) ;
99
123
} ) ;
100
124
101
125
describe ( 'uiValidateWatch' , function ( ) {
0 commit comments