@@ -80,6 +80,13 @@ describe("sidebar pointer lifecycle", () => {
8080 expect ( drag . onFinish ) . toHaveBeenCalledOnce ( ) ;
8181 } ) ;
8282
83+ it ( "moves to the pointer on the move that starts the drag" , ( ) => {
84+ const drag = gesture ( ) ;
85+ document . dispatchEvent ( pointer ( "pointermove" , { clientY : 90 } ) ) ;
86+ expect ( drag . onStart ) . toHaveBeenCalledExactlyOnceWith ( { x : 10 , y : 10 } ) ;
87+ expect ( drag . onMove ) . toHaveBeenCalledExactlyOnceWith ( { x : 10 , y : 90 } ) ;
88+ } ) ;
89+
8390 const interruptions = {
8491 blur : ( ) => window . dispatchEvent ( new Event ( "blur" ) ) ,
8592 hidden : ( ) => {
@@ -122,10 +129,11 @@ describe("sidebar pointer lifecycle", () => {
122129 const drag = gesture ( { onMove, onDrop } ) ;
123130 document . dispatchEvent ( pointer ( "pointermove" , { clientY : 20 } ) ) ;
124131 document . dispatchEvent ( pointer ( "pointermove" , { clientX : 30 , clientY : 30 } ) ) ;
125- expect ( drag . onMove ) . toHaveBeenCalledExactlyOnceWith ( { x : 30 , y : 30 } ) ;
132+ expect ( drag . onMove ) . toHaveBeenNthCalledWith ( 1 , { x : 10 , y : 20 } ) ;
133+ expect ( drag . onMove ) . toHaveBeenNthCalledWith ( 2 , { x : 30 , y : 30 } ) ;
126134 document . dispatchEvent ( pointer ( "pointermove" , { clientX : 90 , clientY : 30 } ) ) ;
127135 // Outside the list the sort no longer sees the pointer.
128- expect ( drag . onMove ) . toHaveBeenCalledOnce ( ) ;
136+ expect ( drag . onMove ) . toHaveBeenCalledTimes ( 2 ) ;
129137 document . dispatchEvent ( pointer ( "pointerup" , { buttons : 0 , clientX : 90 , clientY : 30 } ) ) ;
130138 expect ( onDrop ) . toHaveBeenCalledExactlyOnceWith ( { x : 90 , y : 30 } ) ;
131139 expect ( drag . onCancel ) . toHaveBeenCalledOnce ( ) ;
@@ -148,7 +156,8 @@ describe("sidebar pointer lifecycle", () => {
148156 document . dispatchEvent ( pointer ( "pointermove" , { clientX : 30 , clientY : 30 } ) ) ;
149157 document . dispatchEvent ( pointer ( "pointermove" , { clientX : 90 , clientY : 100 } ) ) ;
150158 document . dispatchEvent ( pointer ( "pointermove" , { clientX : 90 , clientY : 200 } ) ) ;
151- expect ( drag . onMove ) . toHaveBeenCalledExactlyOnceWith ( { x : 30 , y : 30 } ) ;
159+ expect ( drag . onMove ) . toHaveBeenCalledTimes ( 2 ) ;
160+ expect ( drag . onMove ) . toHaveBeenLastCalledWith ( { x : 30 , y : 30 } ) ;
152161
153162 document . dispatchEvent ( pointer ( "pointermove" , { clientX : 30 , clientY : 60 } ) ) ;
154163 expect ( drag . onMove ) . toHaveBeenLastCalledWith ( { x : 30 , y : 60 } ) ;
0 commit comments