11import { inject , TestBed , async , ComponentFixture } from '@angular/core/testing' ;
22import { NgModule , Component , ViewChild , ElementRef } from '@angular/core' ;
3- import { Scroll } from './scroll' ;
3+ import { ScrollDispatcher } from './scroll-dispatcher ' ;
44import { ScrollModule , Scrollable } from './scrollable' ;
55
6- describe ( 'Scrollable ' , ( ) => {
7- let scroll : Scroll ;
6+ describe ( 'Scroll Dispatcher ' , ( ) => {
7+ let scroll : ScrollDispatcher ;
88 let fixture : ComponentFixture < ScrollingComponent > ;
99
1010 beforeEach ( async ( ( ) => {
@@ -15,19 +15,19 @@ describe('Scrollable', () => {
1515 TestBed . compileComponents ( ) ;
1616 } ) ) ;
1717
18- beforeEach ( inject ( [ Scroll ] , ( s : Scroll ) => {
18+ beforeEach ( inject ( [ ScrollDispatcher ] , ( s : ScrollDispatcher ) => {
1919 scroll = s ;
2020
2121 fixture = TestBed . createComponent ( ScrollingComponent ) ;
2222 fixture . detectChanges ( ) ;
2323 } ) ) ;
2424
25- it ( 'should register the scrollable directive with the scroll service' , ( ) => {
25+ it ( 'should be registered with the scrollable directive with the scroll service' , ( ) => {
2626 const componentScrollable = fixture . componentInstance . scrollable ;
2727 expect ( scroll . scrollableReferences . has ( componentScrollable ) ) . toBe ( true ) ;
2828 } ) ;
2929
30- it ( 'should deregister the scrollable directive when the component is destroyed' , ( ) => {
30+ it ( 'should have the scrollable directive deregistered when the component is destroyed' , ( ) => {
3131 const componentScrollable = fixture . componentInstance . scrollable ;
3232 expect ( scroll . scrollableReferences . has ( componentScrollable ) ) . toBe ( true ) ;
3333
@@ -48,7 +48,9 @@ describe('Scrollable', () => {
4848 // Emit a scroll event from the scrolling element in our component.
4949 // This event should be picked up by the scrollable directive and notify.
5050 // The notification should be picked up by the service.
51- fixture . componentInstance . scrollingElement . nativeElement . dispatchEvent ( new Event ( 'scroll' ) ) ;
51+ const scrollEvent = document . createEvent ( 'UIEvents' ) ;
52+ scrollEvent . initUIEvent ( 'scroll' , true , true , window , 0 ) ;
53+ fixture . componentInstance . scrollingElement . nativeElement . dispatchEvent ( scrollEvent ) ;
5254
5355 expect ( hasDirectiveScrollNotified ) . toBe ( true ) ;
5456 expect ( hasServiceScrollNotified ) . toBe ( true ) ;
@@ -58,7 +60,7 @@ describe('Scrollable', () => {
5860
5961/** Simple component that contains a large div and can be scrolled. */
6062@Component ( {
61- template : `<div #scrollingElement md -scrollable style="height: 9999px"></div>`
63+ template : `<div #scrollingElement cdk -scrollable style="height: 9999px"></div>`
6264} )
6365class ScrollingComponent {
6466 @ViewChild ( Scrollable ) scrollable : Scrollable ;
@@ -68,7 +70,7 @@ class ScrollingComponent {
6870const TEST_COMPONENTS = [ ScrollingComponent ] ;
6971@NgModule ( {
7072 imports : [ ScrollModule ] ,
71- providers : [ Scroll ] ,
73+ providers : [ ScrollDispatcher ] ,
7274 exports : TEST_COMPONENTS ,
7375 declarations : TEST_COMPONENTS ,
7476 entryComponents : TEST_COMPONENTS ,
0 commit comments