@@ -469,26 +469,52 @@ describe('ngModelOptions', function() {
469
469
var inputElm = helper . compileInput (
470
470
'<input type="text" ng-model="name" name="alias" ' +
471
471
'ng-model-options="{' +
472
- 'updateOn: \'default blur\', ' +
472
+ 'updateOn: \'default blur mouseup \', ' +
473
473
'debounce: { default: 10000, blur: 5000 }' +
474
474
'}"' +
475
475
'/>' ) ;
476
476
477
477
helper . changeInputValueTo ( 'a' ) ;
478
- expect ( $rootScope . checkbox ) . toBeUndefined ( ) ;
478
+ expect ( $rootScope . name ) . toBeUndefined ( ) ;
479
479
$timeout . flush ( 6000 ) ;
480
- expect ( $rootScope . checkbox ) . toBeUndefined ( ) ;
480
+ expect ( $rootScope . name ) . toBeUndefined ( ) ;
481
481
$timeout . flush ( 4000 ) ;
482
482
expect ( $rootScope . name ) . toEqual ( 'a' ) ;
483
+
483
484
helper . changeInputValueTo ( 'b' ) ;
484
485
browserTrigger ( inputElm , 'blur' ) ;
485
486
$timeout . flush ( 4000 ) ;
486
487
expect ( $rootScope . name ) . toEqual ( 'a' ) ;
487
488
$timeout . flush ( 2000 ) ;
488
489
expect ( $rootScope . name ) . toEqual ( 'b' ) ;
490
+
491
+ helper . changeInputValueTo ( 'c' ) ;
492
+ browserTrigger ( helper . inputElm , 'mouseup' ) ;
493
+ // counter-intuitively `default` in `debounce` is a catch-all
494
+ expect ( $rootScope . name ) . toEqual ( 'b' ) ;
495
+ $timeout . flush ( 10000 ) ;
496
+ expect ( $rootScope . name ) . toEqual ( 'c' ) ;
489
497
} ) ;
490
498
491
499
500
+ it ( 'should trigger immediately for the event if not listed in the debounce list' ,
501
+ function ( ) {
502
+ var inputElm = helper . compileInput (
503
+ '<input type="text" ng-model="name" name="alias" ' +
504
+ 'ng-model-options="{' +
505
+ 'updateOn: \'default blur foo\', ' +
506
+ 'debounce: { blur: 5000 }' +
507
+ '}"' +
508
+ '/>' ) ;
509
+
510
+ helper . changeInputValueTo ( 'a' ) ;
511
+ expect ( $rootScope . name ) . toEqual ( 'a' ) ;
512
+
513
+ helper . changeInputValueTo ( 'b' ) ;
514
+ browserTrigger ( inputElm , 'foo' ) ;
515
+ expect ( $rootScope . name ) . toEqual ( 'b' ) ;
516
+ } ) ;
517
+
492
518
it ( 'should allow selecting different debounce timeouts for each event on checkboxes' , function ( ) {
493
519
var inputElm = helper . compileInput ( '<input type="checkbox" ng-model="checkbox" ' +
494
520
'ng-model-options="{ ' +
0 commit comments