@@ -365,6 +365,60 @@ describe('tooltip', function() {
365
365
} ) ) ;
366
366
} ) ;
367
367
368
+ describe ( 'with specified popup close delay' , function ( ) {
369
+ var $timeout ;
370
+ beforeEach ( inject ( function ( $compile , _$timeout_ ) {
371
+ $timeout = _$timeout_ ;
372
+ scope . delay = '1000' ;
373
+ elm = $compile ( angular . element (
374
+ '<span uib-tooltip="tooltip text" tooltip-popup-close-delay="{{delay}}" ng-disabled="disabled">Selector Text</span>'
375
+ ) ) ( scope ) ;
376
+ elmScope = elm . scope ( ) ;
377
+ tooltipScope = elmScope . $$childTail ;
378
+ scope . $digest ( ) ;
379
+ } ) ) ;
380
+
381
+ it ( 'should close after timeout' , function ( ) {
382
+ trigger ( elm , 'mouseenter' ) ;
383
+ expect ( tooltipScope . isOpen ) . toBe ( true ) ;
384
+ trigger ( elm , 'mouseleave' ) ;
385
+ $timeout . flush ( ) ;
386
+ expect ( tooltipScope . isOpen ) . toBe ( false ) ;
387
+ } ) ;
388
+
389
+ it ( 'should use default popup close delay if specified delay is not a number and close after delay' , function ( ) {
390
+ scope . delay = 'text1000' ;
391
+ scope . $digest ( ) ;
392
+ trigger ( elm , 'mouseenter' ) ;
393
+ expect ( tooltipScope . popupCloseDelay ) . toBe ( 500 ) ;
394
+ expect ( tooltipScope . isOpen ) . toBe ( true ) ;
395
+ trigger ( elm , 'mouseleave' ) ;
396
+ $timeout . flush ( ) ;
397
+ expect ( tooltipScope . isOpen ) . toBe ( false ) ;
398
+ } ) ;
399
+
400
+ it ( 'should open when not disabled after being disabled and close after delay - issue #4204' , function ( ) {
401
+ trigger ( elm , 'mouseenter' ) ;
402
+ expect ( tooltipScope . isOpen ) . toBe ( true ) ;
403
+
404
+ elmScope . disabled = true ;
405
+ elmScope . $digest ( ) ;
406
+
407
+ $timeout . flush ( 500 ) ;
408
+ expect ( tooltipScope . isOpen ) . toBe ( false ) ;
409
+
410
+ elmScope . disabled = false ;
411
+ elmScope . $digest ( ) ;
412
+
413
+ trigger ( elm , 'mouseenter' ) ;
414
+
415
+ expect ( tooltipScope . isOpen ) . toBe ( true ) ;
416
+ trigger ( elm , 'mouseleave' ) ;
417
+ $timeout . flush ( ) ;
418
+ expect ( tooltipScope . isOpen ) . toBe ( false ) ;
419
+ } ) ;
420
+ } ) ;
421
+
368
422
describe ( 'with an is-open attribute' , function ( ) {
369
423
beforeEach ( inject ( function ( $compile ) {
370
424
scope . isOpen = false ;
0 commit comments