@@ -2,7 +2,7 @@ import { DebugElement } from '@angular/core';
22import { fakeAsync , TestBed , tick , flush , waitForAsync , ComponentFixture } from '@angular/core/testing' ;
33import { By } from '@angular/platform-browser' ;
44import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
5- import { IgxTooltipSingleTargetComponent , IgxTooltipMultipleTargetsComponent , IgxTooltipPlainStringComponent , IgxTooltipWithToggleActionComponent , IgxTooltipMultipleTooltipsComponent , IgxTooltipWithCloseButtonComponent , IgxTooltipWithNestedContentComponent } from '../../../../test-utils/tooltip-components.spec' ;
5+ import { IgxTooltipSingleTargetComponent , IgxTooltipMultipleTargetsComponent , IgxTooltipPlainStringComponent , IgxTooltipWithToggleActionComponent , IgxTooltipMultipleTooltipsComponent , IgxTooltipWithCloseButtonComponent , IgxTooltipWithNestedContentComponent , IgxTooltipNestedTooltipsComponent } from '../../../../test-utils/tooltip-components.spec' ;
66import { UIInteractions } from '../../../../test-utils/ui-interactions.spec' ;
77import { HorizontalAlignment , VerticalAlignment , AutoPositionStrategy } from '../../../../core/src/services/public_api' ;
88import { IgxTooltipDirective } from './tooltip.directive' ;
@@ -29,7 +29,8 @@ describe('IgxTooltip', () => {
2929 IgxTooltipPlainStringComponent ,
3030 IgxTooltipWithToggleActionComponent ,
3131 IgxTooltipWithCloseButtonComponent ,
32- IgxTooltipWithNestedContentComponent
32+ IgxTooltipWithNestedContentComponent ,
33+ IgxTooltipNestedTooltipsComponent
3334 ]
3435 } ) . compileComponents ( ) ;
3536 UIInteractions . clearOverlay ( ) ;
@@ -533,6 +534,69 @@ describe('IgxTooltip', () => {
533534 } ) ) ;
534535 } ) ;
535536
537+ describe ( 'Nested tooltips' , ( ) => {
538+ let tooltipTarget1 : IgxTooltipTargetDirective ;
539+ let tooltipTarget2 : IgxTooltipTargetDirective ;
540+ let tooltipTarget3 : IgxTooltipTargetDirective ;
541+
542+ let tooltip1 : IgxTooltipDirective ;
543+ let tooltip2 : IgxTooltipDirective ;
544+ let tooltip3 : IgxTooltipDirective ;
545+
546+ // Handles getting the left offset when tooltip placement is Bottom
547+ const getArrowLeftOffset = ( tooltip : IgxTooltipDirective ) => {
548+ const tooltipRect = tooltip . element . getBoundingClientRect ( ) ;
549+ const arrowRect = tooltip . arrow . getBoundingClientRect ( ) ;
550+
551+ const offset = tooltipRect . width / 2 - arrowRect . width / 2 ;
552+ return Math . round ( offset ) ;
553+ } ;
554+
555+ const verifyTooltipArrowAlignment = ( tooltip : IgxTooltipDirective ) => {
556+ const arrowClassName = 'igx-tooltip--bottom' ;
557+ const arrowTopOffset = '-4px' ;
558+ const arrowLeftOffset = getArrowLeftOffset ( tooltip ) + 'px' ;
559+
560+ expect ( tooltip . arrow . classList . contains ( arrowClassName ) ) . toBeTrue ( ) ;
561+ expect ( tooltip . arrow . style . top ) . toBe ( arrowTopOffset ) ;
562+ expect ( tooltip . arrow . style . left ) . toBe ( arrowLeftOffset ) ;
563+ } ;
564+
565+ beforeEach ( waitForAsync ( ( ) => {
566+ fix = TestBed . createComponent ( IgxTooltipNestedTooltipsComponent ) ;
567+ fix . detectChanges ( ) ;
568+
569+ tooltipTarget1 = fix . componentInstance . targetLevel1 ;
570+ tooltipTarget2 = fix . componentInstance . targetLevel2 ;
571+ tooltipTarget3 = fix . componentInstance . targetLevel3 ;
572+
573+ tooltip1 = fix . componentInstance . tooltipLevel1 ;
574+ tooltip2 = fix . componentInstance . tooltipLevel2 ;
575+ tooltip3 = fix . componentInstance . tooltipLevel3 ;
576+ } ) ) ;
577+
578+ it ( 'should show arrow for each tooltip' , fakeAsync ( ( ) => {
579+ hoverElement ( tooltipTarget1 ) ;
580+ flush ( ) ;
581+ verifyTooltipVisibility ( tooltip1 . element , tooltipTarget1 , true ) ;
582+ expect ( tooltipTarget1 . hasArrow ) . toBeTrue ( ) ;
583+ verifyTooltipArrowAlignment ( tooltip1 ) ;
584+
585+ hoverElement ( tooltipTarget2 ) ;
586+ flush ( ) ;
587+ verifyTooltipVisibility ( tooltip2 . element , tooltipTarget2 , true ) ;
588+ expect ( tooltipTarget2 . hasArrow ) . toBeTrue ( ) ;
589+ verifyTooltipArrowAlignment ( tooltip2 ) ;
590+
591+ hoverElement ( tooltipTarget3 ) ;
592+ flush ( ) ;
593+ verifyTooltipVisibility ( tooltip3 . element , tooltipTarget3 , true ) ;
594+ expect ( tooltipTarget3 . hasArrow ) . toBeTrue ( ) ;
595+ verifyTooltipArrowAlignment ( tooltip3 ) ;
596+
597+ } ) ) ;
598+ } ) ;
599+
536600 describe ( 'Multiple targets with single tooltip' , ( ) => {
537601 let targetOne : IgxTooltipTargetDirective ;
538602 let targetTwo : IgxTooltipTargetDirective ;
0 commit comments