11import {
2- async ,
3- ComponentFixture ,
4- TestBed ,
5- tick ,
6- fakeAsync ,
7- flushMicrotasks
2+ async ,
3+ ComponentFixture ,
4+ TestBed ,
5+ tick ,
6+ fakeAsync ,
7+ flushMicrotasks
88} from '@angular/core/testing' ;
9- import { Component , DebugElement , AnimationTransitionEvent , ViewChild } from '@angular/core' ;
9+ import { Component , DebugElement , AnimationTransitionEvent } from '@angular/core' ;
1010import { By } from '@angular/platform-browser' ;
1111import { TooltipPosition , MdTooltip , MdTooltipModule } from './tooltip' ;
1212import { OverlayContainer } from '../core' ;
1313import { Dir , LayoutDirection } from '../core/rtl/dir' ;
1414import { OverlayModule } from '../core/overlay/overlay-directives' ;
15- import { Scrollable } from '../core/overlay/scroll/scrollable' ;
1615
1716const initialTooltipMessage = 'initial tooltip message' ;
1817
@@ -23,7 +22,7 @@ describe('MdTooltip', () => {
2322 beforeEach ( async ( ( ) => {
2423 TestBed . configureTestingModule ( {
2524 imports : [ MdTooltipModule . forRoot ( ) , OverlayModule ] ,
26- declarations : [ BasicTooltipDemo , ScrollableTooltipDemo ] ,
25+ declarations : [ BasicTooltipDemo ] ,
2726 providers : [
2827 { provide : OverlayContainer , useFactory : ( ) => {
2928 overlayContainerElement = document . createElement ( 'div' ) ;
@@ -298,34 +297,6 @@ describe('MdTooltip', () => {
298297 } ) . toThrowError ( 'Tooltip position "everywhere" is invalid.' ) ;
299298 } ) ;
300299 } ) ;
301-
302-
303- describe ( 'scrollable usage' , ( ) => {
304- let fixture : ComponentFixture < ScrollableTooltipDemo > ;
305- let buttonDebugElement : DebugElement ;
306- let buttonElement : HTMLButtonElement ;
307- let tooltipDirective : MdTooltip ;
308-
309- beforeEach ( ( ) => {
310- fixture = TestBed . createComponent ( ScrollableTooltipDemo ) ;
311- fixture . detectChanges ( ) ;
312- buttonDebugElement = fixture . debugElement . query ( By . css ( 'button' ) ) ;
313- buttonElement = < HTMLButtonElement > buttonDebugElement . nativeElement ;
314- tooltipDirective = buttonDebugElement . injector . get ( MdTooltip ) ;
315- } ) ;
316-
317- it ( 'should hide tooltip if clipped after changing positions' , fakeAsync ( ( ) => {
318- expect ( tooltipDirective . _tooltipInstance ) . toBeUndefined ( ) ;
319-
320- tooltipDirective . show ( ) ;
321- tick ( 0 ) ; // Tick for the show delay (default is 0)
322- expect ( tooltipDirective . _isTooltipVisible ( ) ) . toBe ( true ) ;
323-
324- fixture . componentInstance . scrollDown ( ) ;
325- tick ( ) ;
326- expect ( tooltipDirective . _isTooltipVisible ( ) ) . toBe ( false ) ;
327- } ) ) ;
328- } ) ;
329300} ) ;
330301
331302@Component ( {
@@ -343,33 +314,3 @@ class BasicTooltipDemo {
343314 showButton : boolean = true ;
344315}
345316
346- @Component ( {
347- selector : 'app' ,
348- template : `
349- <div cdk-scrollable style="margin-top: 300px; height: 200px; width: 200px; overflow: auto;">
350- <button *ngIf="showButton" style="margin-bottom: 350px"
351- [md-tooltip]="message"
352- [tooltip-position]="position">
353- Button
354- </button>
355- </div>`
356- } )
357- class ScrollableTooltipDemo {
358- position : string = 'below' ;
359- message : string = initialTooltipMessage ;
360- showButton : boolean = true ;
361-
362- @ViewChild ( Scrollable ) scrollingContainer : Scrollable ;
363-
364- scrollDown ( ) {
365- const scrollingContainerEl = this . scrollingContainer . getElementRef ( ) . nativeElement ;
366- scrollingContainerEl . scrollTop = 50 ;
367-
368- // Emit a scroll event from the scrolling element in our component.
369- // This event should be picked up by the scrollable directive and notify.
370- // The notification should be picked up by the service.
371- const scrollEvent = document . createEvent ( 'UIEvents' ) ;
372- scrollEvent . initUIEvent ( 'scroll' , true , true , window , 0 ) ;
373- scrollingContainerEl . dispatchEvent ( scrollEvent ) ;
374- }
375- }
0 commit comments