@@ -498,9 +498,41 @@ describe('ngModelOptions', function() {
498
498
499
499
helper . changeInputValueTo ( 'c' ) ;
500
500
browserTrigger ( helper . inputElm , 'mouseup' ) ;
501
- // counter-intuitively `default` in `debounce` is a catch-all
501
+ // `default` in `debounce` only affects the event triggers that are not defined in updateOn
502
+ expect ( $rootScope . name ) . toEqual ( 'c' ) ;
503
+ } ) ;
504
+
505
+
506
+ it ( 'should use the value of * to debounce all unspecified events' ,
507
+ function ( ) {
508
+ var inputElm = helper . compileInput (
509
+ '<input type="text" ng-model="name" name="alias" ' +
510
+ 'ng-model-options="{' +
511
+ 'updateOn: \'default blur mouseup\', ' +
512
+ 'debounce: { default: 10000, blur: 5000, \'*\': 15000 }' +
513
+ '}"' +
514
+ '/>' ) ;
515
+
516
+ helper . changeInputValueTo ( 'a' ) ;
517
+ expect ( $rootScope . name ) . toBeUndefined ( ) ;
518
+ $timeout . flush ( 6000 ) ;
519
+ expect ( $rootScope . name ) . toBeUndefined ( ) ;
520
+ $timeout . flush ( 4000 ) ;
521
+ expect ( $rootScope . name ) . toEqual ( 'a' ) ;
522
+
523
+ helper . changeInputValueTo ( 'b' ) ;
524
+ browserTrigger ( inputElm , 'blur' ) ;
525
+ $timeout . flush ( 4000 ) ;
526
+ expect ( $rootScope . name ) . toEqual ( 'a' ) ;
527
+ $timeout . flush ( 2000 ) ;
502
528
expect ( $rootScope . name ) . toEqual ( 'b' ) ;
503
- $timeout . flush ( 10000 ) ;
529
+
530
+ helper . changeInputValueTo ( 'c' ) ;
531
+ browserTrigger ( helper . inputElm , 'mouseup' ) ;
532
+ expect ( $rootScope . name ) . toEqual ( 'b' ) ;
533
+ $timeout . flush ( 10000 ) ; // flush default
534
+ expect ( $rootScope . name ) . toEqual ( 'b' ) ;
535
+ $timeout . flush ( 5000 ) ;
504
536
expect ( $rootScope . name ) . toEqual ( 'c' ) ;
505
537
} ) ;
506
538
0 commit comments