File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -254,6 +254,20 @@ describe('validators', function() {
254254 expect ( $rootScope . value ) . toBe ( 12345 ) ;
255255 expect ( $rootScope . form . input . $error . minlength ) . toBeUndefined ( ) ;
256256 } ) ;
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+ } ) ;
257271 } ) ;
258272
259273
@@ -517,5 +531,19 @@ describe('validators', function() {
517531 $rootScope . $apply ( "answer = false" ) ;
518532 expect ( inputElm ) . toBeValid ( ) ;
519533 } ) ;
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+ } ) ;
520548 } ) ;
521549} ) ;
You can’t perform that action at this time.
0 commit comments