@@ -9,10 +9,11 @@ import {
9
9
} from '../testing/private' ;
10
10
import { DragDropRegistry } from './drag-drop-registry' ;
11
11
import { DragDropModule } from './drag-drop-module' ;
12
+ import { DragRef } from './drag-ref' ;
12
13
13
14
describe ( 'DragDropRegistry' , ( ) => {
14
15
let fixture : ComponentFixture < BlankComponent > ;
15
- let registry : DragDropRegistry < DragItem , DragList > ;
16
+ let registry : DragDropRegistry ;
16
17
17
18
beforeEach ( fakeAsync ( ( ) => {
18
19
TestBed . configureTestingModule ( {
@@ -22,21 +23,21 @@ describe('DragDropRegistry', () => {
22
23
fixture = TestBed . createComponent ( BlankComponent ) ;
23
24
fixture . detectChanges ( ) ;
24
25
25
- inject ( [ DragDropRegistry ] , ( c : DragDropRegistry < DragItem , DragList > ) => {
26
+ inject ( [ DragDropRegistry ] , ( c : DragDropRegistry ) => {
26
27
registry = c ;
27
28
} ) ( ) ;
28
29
} ) ) ;
29
30
30
31
it ( 'should be able to start dragging an item' , ( ) => {
31
- const item = new DragItem ( ) ;
32
+ const item = new DragItem ( ) as unknown as DragRef ;
32
33
33
34
expect ( registry . isDragging ( item ) ) . toBe ( false ) ;
34
35
registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
35
36
expect ( registry . isDragging ( item ) ) . toBe ( true ) ;
36
37
} ) ;
37
38
38
39
it ( 'should be able to stop dragging an item' , ( ) => {
39
- const item = new DragItem ( ) ;
40
+ const item = new DragItem ( ) as unknown as DragRef ;
40
41
41
42
registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
42
43
expect ( registry . isDragging ( item ) ) . toBe ( true ) ;
@@ -46,7 +47,7 @@ describe('DragDropRegistry', () => {
46
47
} ) ;
47
48
48
49
it ( 'should stop dragging an item if it is removed' , ( ) => {
49
- const item = new DragItem ( ) ;
50
+ const item = new DragItem ( ) as unknown as DragRef ;
50
51
51
52
registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
52
53
expect ( registry . isDragging ( item ) ) . toBe ( true ) ;
@@ -58,7 +59,7 @@ describe('DragDropRegistry', () => {
58
59
it ( 'should dispatch `mousemove` events after starting to drag via the mouse' , ( ) => {
59
60
const spy = jasmine . createSpy ( 'pointerMove spy' ) ;
60
61
const subscription = registry . pointerMove . subscribe ( spy ) ;
61
- const item = new DragItem ( true ) ;
62
+ const item = new DragItem ( true ) as unknown as DragRef ;
62
63
registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
63
64
dispatchMouseEvent ( document , 'mousemove' ) ;
64
65
@@ -70,7 +71,7 @@ describe('DragDropRegistry', () => {
70
71
it ( 'should dispatch `touchmove` events after starting to drag via touch' , ( ) => {
71
72
const spy = jasmine . createSpy ( 'pointerMove spy' ) ;
72
73
const subscription = registry . pointerMove . subscribe ( spy ) ;
73
- const item = new DragItem ( true ) ;
74
+ const item = new DragItem ( true ) as unknown as DragRef ;
74
75
registry . startDragging ( item , createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
75
76
dispatchTouchEvent ( document , 'touchmove' ) ;
76
77
@@ -82,7 +83,7 @@ describe('DragDropRegistry', () => {
82
83
it ( 'should dispatch pointer move events if event propagation is stopped' , ( ) => {
83
84
const spy = jasmine . createSpy ( 'pointerMove spy' ) ;
84
85
const subscription = registry . pointerMove . subscribe ( spy ) ;
85
- const item = new DragItem ( true ) ;
86
+ const item = new DragItem ( true ) as unknown as DragRef ;
86
87
fixture . nativeElement . addEventListener ( 'mousemove' , ( e : MouseEvent ) => e . stopPropagation ( ) ) ;
87
88
registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
88
89
dispatchMouseEvent ( fixture . nativeElement , 'mousemove' ) ;
@@ -95,7 +96,7 @@ describe('DragDropRegistry', () => {
95
96
it ( 'should dispatch `mouseup` events after ending the drag via the mouse' , ( ) => {
96
97
const spy = jasmine . createSpy ( 'pointerUp spy' ) ;
97
98
const subscription = registry . pointerUp . subscribe ( spy ) ;
98
- const item = new DragItem ( ) ;
99
+ const item = new DragItem ( ) as unknown as DragRef ;
99
100
100
101
registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
101
102
dispatchMouseEvent ( document , 'mouseup' ) ;
@@ -108,7 +109,7 @@ describe('DragDropRegistry', () => {
108
109
it ( 'should dispatch `touchend` events after ending the drag via touch' , ( ) => {
109
110
const spy = jasmine . createSpy ( 'pointerUp spy' ) ;
110
111
const subscription = registry . pointerUp . subscribe ( spy ) ;
111
- const item = new DragItem ( ) ;
112
+ const item = new DragItem ( ) as unknown as DragRef ;
112
113
113
114
registry . startDragging ( item , createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
114
115
dispatchTouchEvent ( document , 'touchend' ) ;
@@ -121,7 +122,7 @@ describe('DragDropRegistry', () => {
121
122
it ( 'should dispatch pointer up events if event propagation is stopped' , ( ) => {
122
123
const spy = jasmine . createSpy ( 'pointerUp spy' ) ;
123
124
const subscription = registry . pointerUp . subscribe ( spy ) ;
124
- const item = new DragItem ( ) ;
125
+ const item = new DragItem ( ) as unknown as DragRef ;
125
126
126
127
fixture . nativeElement . addEventListener ( 'mouseup' , ( e : MouseEvent ) => e . stopPropagation ( ) ) ;
127
128
registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
@@ -148,7 +149,7 @@ describe('DragDropRegistry', () => {
148
149
} ) ;
149
150
150
151
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 ;
152
153
153
154
// First finger down
154
155
registry . startDragging ( item , createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
@@ -183,7 +184,7 @@ describe('DragDropRegistry', () => {
183
184
} ) ;
184
185
185
186
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 ;
187
188
registry . startDragging ( item , createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
188
189
expect ( dispatchTouchEvent ( document , 'touchmove' ) . defaultPrevented ) . toBe ( true ) ;
189
190
} ) ;
@@ -192,7 +193,7 @@ describe('DragDropRegistry', () => {
192
193
'should prevent the default `touchmove` if the item does not consider itself as being ' +
193
194
'dragged yet' ,
194
195
( ) => {
195
- const item = new DragItem ( false ) ;
196
+ const item = new DragItem ( false ) as unknown as DragRef & DragItem ;
196
197
registry . startDragging ( item , createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
197
198
expect ( dispatchTouchEvent ( document , 'touchmove' ) . defaultPrevented ) . toBe ( false ) ;
198
199
@@ -202,7 +203,7 @@ describe('DragDropRegistry', () => {
202
203
) ;
203
204
204
205
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 ;
206
207
registry . startDragging ( item , createTouchEvent ( 'touchstart' ) as TouchEvent ) ;
207
208
fixture . nativeElement . addEventListener ( 'touchmove' , ( e : TouchEvent ) => e . stopPropagation ( ) ) ;
208
209
@@ -215,15 +216,15 @@ describe('DragDropRegistry', () => {
215
216
} ) ;
216
217
217
218
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 ;
219
220
registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
220
221
expect ( dispatchFakeEvent ( document , 'selectstart' ) . defaultPrevented ) . toBe ( true ) ;
221
222
} ) ;
222
223
223
224
it ( 'should dispatch `scroll` events if the viewport is scrolled while dragging' , ( ) => {
224
225
const spy = jasmine . createSpy ( 'scroll spy' ) ;
225
226
const subscription = registry . scrolled ( ) . subscribe ( spy ) ;
226
- const item = new DragItem ( ) ;
227
+ const item = new DragItem ( ) as unknown as DragRef ;
227
228
228
229
registry . startDragging ( item , createMouseEvent ( 'mousedown' ) ) ;
229
230
dispatchFakeEvent ( document , 'scroll' ) ;
@@ -247,13 +248,7 @@ describe('DragDropRegistry', () => {
247
248
return this . shouldBeDragging ;
248
249
}
249
250
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 ) ;
257
252
}
258
253
}
259
254
0 commit comments