@@ -446,6 +446,58 @@ describe('tooltipWithDifferentSymbols', function() {
446
446
447
447
} ) ;
448
448
449
+ describe ( 'tooltip positioning' , function ( ) {
450
+ var elm , elmBody , elmScope , tooltipScope , scope ;
451
+ var $position ;
452
+
453
+ // load the tooltip code
454
+ beforeEach ( module ( 'ui.bootstrap.tooltip' , function ( $tooltipProvider ) {
455
+ $tooltipProvider . options ( { animation : false } ) ;
456
+ } ) ) ;
457
+
458
+ // load the template
459
+ beforeEach ( module ( 'template/tooltip/tooltip-popup.html' ) ) ;
460
+
461
+ beforeEach ( inject ( function ( $rootScope , $compile , _$position_ ) {
462
+ $position = _$position_ ;
463
+ spyOn ( $position , 'positionElements' ) . andCallThrough ( ) ;
464
+
465
+ scope = $rootScope ;
466
+ scope . text = 'Some Text' ;
467
+
468
+ elmBody = $compile ( angular . element (
469
+ '<div><span tooltip="{{ text }}">Selector Text</span></div>'
470
+ ) ) ( scope ) ;
471
+ scope . $digest ( ) ;
472
+ elm = elmBody . find ( 'span' ) ;
473
+ elmScope = elm . scope ( ) ;
474
+ tooltipScope = elmScope . $$childTail ;
475
+ } ) ) ;
476
+
477
+ it ( 'should re-position on every digest' , inject ( function ( $timeout ) {
478
+ elm . trigger ( 'mouseenter' ) ;
479
+
480
+ scope . $digest ( ) ;
481
+ $timeout . flush ( ) ;
482
+ var startingPositionCalls = $position . positionElements . calls . length ;
483
+
484
+ scope . $digest ( ) ;
485
+ $timeout . flush ( ) ;
486
+ expect ( $position . positionElements . calls . length ) . toEqual ( startingPositionCalls + 1 ) ;
487
+ // Check that positionElements was called with elm
488
+ expect ( $position . positionElements . calls [ startingPositionCalls ] . args [ 0 ] [ 0 ] )
489
+ . toBe ( elm [ 0 ] ) ;
490
+
491
+ scope . $digest ( ) ;
492
+ $timeout . flush ( ) ;
493
+ expect ( $position . positionElements . calls . length ) . toEqual ( startingPositionCalls + 2 ) ;
494
+ expect ( $position . positionElements . calls [ startingPositionCalls + 1 ] . args [ 0 ] [ 0 ] )
495
+ . toBe ( elm [ 0 ] ) ;
496
+ scope . $digest ( ) ;
497
+ } ) ) ;
498
+
499
+ } ) ;
500
+
449
501
describe ( 'tooltipHtmlUnsafe' , function ( ) {
450
502
var elm , elmBody , elmScope , tooltipScope , scope ;
451
503
0 commit comments