@@ -9,10 +9,11 @@ import {
99} from '../testing/private' ;
1010import { DragDropRegistry } from './drag-drop-registry' ;
1111import { DragDropModule } from './drag-drop-module' ;
12+ import { DragRef } from './drag-ref' ;
1213
1314describe ( 'DragDropRegistry' , ( ) => {
1415 let fixture : ComponentFixture < BlankComponent > ;
15- let registry : DragDropRegistry < DragItem , DragList > ;
16+ let registry : DragDropRegistry ;
1617
1718 beforeEach ( fakeAsync ( ( ) => {
1819 TestBed . configureTestingModule ( {
@@ -22,21 +23,21 @@ describe('DragDropRegistry', () => {
2223 fixture = TestBed . createComponent ( BlankComponent ) ;
2324 fixture . detectChanges ( ) ;
2425
25- inject ( [ DragDropRegistry ] , ( c : DragDropRegistry < DragItem , DragList > ) => {
26+ inject ( [ DragDropRegistry ] , ( c : DragDropRegistry ) => {
2627 registry = c ;
2728 } ) ( ) ;
2829 } ) ) ;
2930
3031 it ( 'should be able to start dragging an item' , ( ) => {
31- const item = new DragItem ( ) ;
32+ const item = new DragItem ( ) as unknown as DragRef ;
3233
3334 expect ( registry . isDragging ( item ) ) . toBe ( false ) ;
3435 registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
3536 expect ( registry . isDragging ( item ) ) . toBe ( true ) ;
3637 } ) ;
3738
3839 it ( 'should be able to stop dragging an item' , ( ) => {
39- const item = new DragItem ( ) ;
40+ const item = new DragItem ( ) as unknown as DragRef ;
4041
4142 registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
4243 expect ( registry . isDragging ( item ) ) . toBe ( true ) ;
@@ -46,7 +47,7 @@ describe('DragDropRegistry', () => {
4647 } ) ;
4748
4849 it ( 'should stop dragging an item if it is removed' , ( ) => {
49- const item = new DragItem ( ) ;
50+ const item = new DragItem ( ) as unknown as DragRef ;
5051
5152 registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
5253 expect ( registry . isDragging ( item ) ) . toBe ( true ) ;
@@ -58,7 +59,7 @@ describe('DragDropRegistry', () => {
5859 it ( 'should dispatch `mousemove` events after starting to drag via the mouse' , ( ) => {
5960 const spy = jasmine . createSpy ( 'pointerMove spy' ) ;
6061 const subscription = registry . pointerMove . subscribe ( spy ) ;
61- const item = new DragItem ( true ) ;
62+ const item = new DragItem ( true ) as unknown as DragRef ;
6263 registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
6364 dispatchMouseEvent ( document , 'mousemove' ) ;
6465
@@ -70,7 +71,7 @@ describe('DragDropRegistry', () => {
7071 it ( 'should dispatch `touchmove` events after starting to drag via touch' , ( ) => {
7172 const spy = jasmine . createSpy ( 'pointerMove spy' ) ;
7273 const subscription = registry . pointerMove . subscribe ( spy ) ;
73- const item = new DragItem ( true ) ;
74+ const item = new DragItem ( true ) as unknown as DragRef ;
7475 registry . startDragging ( item , createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
7576 dispatchTouchEvent ( document , 'touchmove' ) ;
7677
@@ -82,7 +83,7 @@ describe('DragDropRegistry', () => {
8283 it ( 'should dispatch pointer move events if event propagation is stopped' , ( ) => {
8384 const spy = jasmine . createSpy ( 'pointerMove spy' ) ;
8485 const subscription = registry . pointerMove . subscribe ( spy ) ;
85- const item = new DragItem ( true ) ;
86+ const item = new DragItem ( true ) as unknown as DragRef ;
8687 fixture . nativeElement . addEventListener ( 'mousemove' , ( e : MouseEvent ) => e . stopPropagation ( ) ) ;
8788 registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
8889 dispatchMouseEvent ( fixture . nativeElement , 'mousemove' ) ;
@@ -95,7 +96,7 @@ describe('DragDropRegistry', () => {
9596 it ( 'should dispatch `mouseup` events after ending the drag via the mouse' , ( ) => {
9697 const spy = jasmine . createSpy ( 'pointerUp spy' ) ;
9798 const subscription = registry . pointerUp . subscribe ( spy ) ;
98- const item = new DragItem ( ) ;
99+ const item = new DragItem ( ) as unknown as DragRef ;
99100
100101 registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
101102 dispatchMouseEvent ( document , 'mouseup' ) ;
@@ -108,7 +109,7 @@ describe('DragDropRegistry', () => {
108109 it ( 'should dispatch `touchend` events after ending the drag via touch' , ( ) => {
109110 const spy = jasmine . createSpy ( 'pointerUp spy' ) ;
110111 const subscription = registry . pointerUp . subscribe ( spy ) ;
111- const item = new DragItem ( ) ;
112+ const item = new DragItem ( ) as unknown as DragRef ;
112113
113114 registry . startDragging ( item , createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
114115 dispatchTouchEvent ( document , 'touchend' ) ;
@@ -121,7 +122,7 @@ describe('DragDropRegistry', () => {
121122 it ( 'should dispatch pointer up events if event propagation is stopped' , ( ) => {
122123 const spy = jasmine . createSpy ( 'pointerUp spy' ) ;
123124 const subscription = registry . pointerUp . subscribe ( spy ) ;
124- const item = new DragItem ( ) ;
125+ const item = new DragItem ( ) as unknown as DragRef ;
125126
126127 fixture . nativeElement . addEventListener ( 'mouseup' , ( e : MouseEvent ) => e . stopPropagation ( ) ) ;
127128 registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
@@ -148,7 +149,7 @@ describe('DragDropRegistry', () => {
148149 } ) ;
149150
150151 it ( 'should not emit pointer events when dragging is over (multi touch)' , ( ) => {
151- const item = new DragItem ( ) ;
152+ const item = new DragItem ( ) as unknown as DragRef ;
152153
153154 // First finger down
154155 registry . startDragging ( item , createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
@@ -183,7 +184,7 @@ describe('DragDropRegistry', () => {
183184 } ) ;
184185
185186 it ( 'should prevent the default `touchmove` action when an item is being dragged' , ( ) => {
186- const item = new DragItem ( true ) ;
187+ const item = new DragItem ( true ) as unknown as DragRef ;
187188 registry . startDragging ( item , createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
188189 expect ( dispatchTouchEvent ( document , 'touchmove' ) . defaultPrevented ) . toBe ( true ) ;
189190 } ) ;
@@ -192,7 +193,7 @@ describe('DragDropRegistry', () => {
192193 'should prevent the default `touchmove` if the item does not consider itself as being ' +
193194 'dragged yet' ,
194195 ( ) => {
195- const item = new DragItem ( false ) ;
196+ const item = new DragItem ( false ) as unknown as DragRef & DragItem ;
196197 registry . startDragging ( item , createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
197198 expect ( dispatchTouchEvent ( document , 'touchmove' ) . defaultPrevented ) . toBe ( false ) ;
198199
@@ -202,7 +203,7 @@ describe('DragDropRegistry', () => {
202203 ) ;
203204
204205 it ( 'should prevent the default `touchmove` if event propagation is stopped' , ( ) => {
205- const item = new DragItem ( true ) ;
206+ const item = new DragItem ( true ) as unknown as DragRef ;
206207 registry . startDragging ( item , createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
207208 fixture . nativeElement . addEventListener ( 'touchmove' , ( e : TouchEvent ) => e . stopPropagation ( ) ) ;
208209
@@ -215,15 +216,15 @@ describe('DragDropRegistry', () => {
215216 } ) ;
216217
217218 it ( 'should prevent the default `selectstart` action when an item is being dragged' , ( ) => {
218- const item = new DragItem ( true ) ;
219+ const item = new DragItem ( true ) as unknown as DragRef ;
219220 registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
220221 expect ( dispatchFakeEvent ( document , 'selectstart' ) . defaultPrevented ) . toBe ( true ) ;
221222 } ) ;
222223
223224 it ( 'should dispatch `scroll` events if the viewport is scrolled while dragging' , ( ) => {
224225 const spy = jasmine . createSpy ( 'scroll spy' ) ;
225226 const subscription = registry . scrolled ( ) . subscribe ( spy ) ;
226- const item = new DragItem ( ) ;
227+ const item = new DragItem ( ) as unknown as DragRef ;
227228
228229 registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
229230 dispatchFakeEvent ( document , 'scroll' ) ;
@@ -247,13 +248,7 @@ describe('DragDropRegistry', () => {
247248 return this . shouldBeDragging ;
248249 }
249250 constructor ( public shouldBeDragging = false ) {
250- registry . registerDragItem ( this ) ;
251- }
252- }
253-
254- class DragList {
255- constructor ( ) {
256- registry . registerDropContainer ( this ) ;
251+ registry . registerDragItem ( this as unknown as DragRef ) ;
257252 }
258253 }
259254
0 commit comments