This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,20 @@ describe('validators', function() {
254
254
expect ( $rootScope . value ) . toBe ( 12345 ) ;
255
255
expect ( $rootScope . form . input . $error . minlength ) . toBeUndefined ( ) ;
256
256
} ) ;
257
+
258
+ it ( 'should validate emptiness against the viewValue' , function ( ) {
259
+ var inputElm = helper . compileInput ( '<input type="text" name="input" ng-model="value" minlength="3" />' ) ;
260
+
261
+ var ctrl = inputElm . controller ( 'ngModel' ) ;
262
+ spyOn ( ctrl , '$isEmpty' ) . andCallThrough ( ) ;
263
+
264
+ ctrl . $parsers . push ( function ( value ) {
265
+ return value + '678' ;
266
+ } ) ;
267
+
268
+ helper . changeInputValueTo ( '12345' ) ;
269
+ expect ( ctrl . $isEmpty ) . toHaveBeenCalledWith ( '12345' ) ;
270
+ } ) ;
257
271
} ) ;
258
272
259
273
@@ -517,5 +531,19 @@ describe('validators', function() {
517
531
$rootScope . $apply ( "answer = false" ) ;
518
532
expect ( inputElm ) . toBeValid ( ) ;
519
533
} ) ;
534
+
535
+ it ( 'should validate emptiness against the viewValue' , function ( ) {
536
+ var inputElm = helper . compileInput ( '<input type="text" name="input" ng-model="value" required />' ) ;
537
+
538
+ var ctrl = inputElm . controller ( 'ngModel' ) ;
539
+ spyOn ( ctrl , '$isEmpty' ) . andCallThrough ( ) ;
540
+
541
+ ctrl . $parsers . push ( function ( value ) {
542
+ return value + '678' ;
543
+ } ) ;
544
+
545
+ helper . changeInputValueTo ( '12345' ) ;
546
+ expect ( ctrl . $isEmpty ) . toHaveBeenCalledWith ( '12345' ) ;
547
+ } ) ;
520
548
} ) ;
521
549
} ) ;
You can’t perform that action at this time.
0 commit comments