@@ -32,44 +32,55 @@ function gestureDefinition() {
3232}
3333
3434describe ( 'gesture run dispatch' , ( ) => {
35+ // Each entry pins both halves of the run projection: which
36+ // `client.interactions.*` method the kind routes to and how its payload
37+ // lands on that method's options (`gesture.test.ts` covers the reader and
38+ // daemon writer, not this client-side projection).
3539 test . for ( [
36- { argv : [ 'pan' , '10' , '20' , '5' , '6' , '300' ] , method : 'pan' } ,
37- { argv : [ 'fling' , 'up' , '10' , '20' , '400' ] , method : 'fling' } ,
38- { argv : [ 'swipe' , 'left-edge' ] , method : 'swipeGesture' } ,
39- { argv : [ 'pinch' , '2' , '30' , '40' ] , method : 'pinch' } ,
40- { argv : [ 'rotate' , '45' ] , method : 'rotateGesture' } ,
41- { argv : [ 'transform' , '10' , '20' , '5' , '6' , '1.5' , '45' , '250' ] , method : 'transformGesture' } ,
42- { argv : [ 'drag' , 'id="drag-source"' , '@e2~s42' , '700' , '600' , '200' ] , method : 'drag' } ,
43- ] ) ( '%argv routes to client.interactions.%method' , async ( { argv, method } ) => {
44- const calls : Array < { method : string ; options : unknown } > = [ ] ;
45- const input = gestureCliReaders . gesture ( argv , NO_FLAGS ) ;
46- await gestureDefinition ( ) . invoke ( recordingGestureClient ( calls ) , input ) ;
47- expect ( calls ) . toHaveLength ( 1 ) ;
48- expect ( calls [ 0 ] ?. method ) . toBe ( method ) ;
49- } ) ;
50-
51- test ( 'pan projects origin/delta and the timed movement onto client options' , async ( ) => {
52- const calls : Array < { method : string ; options : unknown } > = [ ] ;
53- const input = gestureCliReaders . gesture ( [ 'pan' , '10' , '20' , '5' , '6' , '300' ] , NO_FLAGS ) ;
54- await gestureDefinition ( ) . invoke ( recordingGestureClient ( calls ) , input ) ;
55- expect ( calls [ 0 ] ?. options ) . toMatchObject ( { x : 10 , y : 20 , dx : 5 , dy : 6 , durationMs : 300 } ) ;
56- } ) ;
57-
58- test ( 'drag projects selectors and hold durations onto client options' , async ( ) => {
59- const calls : Array < { method : string ; options : unknown } > = [ ] ;
60- const input = gestureCliReaders . gesture (
61- [ 'drag' , 'id="drag-source"' , '@e2~s42' , '700' , '600' , '200' ] ,
62- NO_FLAGS ,
63- ) ;
64- await gestureDefinition ( ) . invoke ( recordingGestureClient ( calls ) , input ) ;
65- expect ( calls [ 0 ] ?. options ) . toMatchObject ( {
66- source : 'id="drag-source"' ,
67- destination : '@e2~s42' ,
68- sourceHoldMs : 700 ,
69- moveMs : 600 ,
70- destinationHoldMs : 200 ,
71- } ) ;
72- } ) ;
40+ {
41+ argv : [ 'pan' , '10' , '20' , '5' , '6' , '300' ] ,
42+ method : 'pan' ,
43+ options : { x : 10 , y : 20 , dx : 5 , dy : 6 , durationMs : 300 } ,
44+ } ,
45+ {
46+ argv : [ 'fling' , 'up' , '10' , '20' , '400' ] ,
47+ method : 'fling' ,
48+ options : { direction : 'up' , x : 10 , y : 20 , distance : 400 } ,
49+ } ,
50+ { argv : [ 'swipe' , 'left-edge' ] , method : 'swipeGesture' , options : { preset : 'left-edge' } } ,
51+ { argv : [ 'pinch' , '2' , '30' , '40' ] , method : 'pinch' , options : { scale : 2 , x : 30 , y : 40 } } ,
52+ {
53+ argv : [ 'rotate' , '45' , '10' , '20' ] ,
54+ method : 'rotateGesture' ,
55+ options : { degrees : 45 , x : 10 , y : 20 } ,
56+ } ,
57+ {
58+ argv : [ 'transform' , '10' , '20' , '5' , '6' , '1.5' , '45' , '250' ] ,
59+ method : 'transformGesture' ,
60+ options : { x : 10 , y : 20 , dx : 5 , dy : 6 , scale : 1.5 , degrees : 45 , durationMs : 250 } ,
61+ } ,
62+ {
63+ argv : [ 'drag' , 'id="drag-source"' , '@e2~s42' , '700' , '600' , '200' ] ,
64+ method : 'drag' ,
65+ options : {
66+ source : 'id="drag-source"' ,
67+ destination : '@e2~s42' ,
68+ sourceHoldMs : 700 ,
69+ moveMs : 600 ,
70+ destinationHoldMs : 200 ,
71+ } ,
72+ } ,
73+ ] ) (
74+ '%argv routes to client.interactions.%method with projected options' ,
75+ async ( { argv, method, options } ) => {
76+ const calls : Array < { method : string ; options : unknown } > = [ ] ;
77+ const input = gestureCliReaders . gesture ( argv , NO_FLAGS ) ;
78+ await gestureDefinition ( ) . invoke ( recordingGestureClient ( calls ) , input ) ;
79+ expect ( calls ) . toHaveLength ( 1 ) ;
80+ expect ( calls [ 0 ] ?. method ) . toBe ( method ) ;
81+ expect ( calls [ 0 ] ?. options ) . toMatchObject ( options ) ;
82+ } ,
83+ ) ;
7384
7485 test ( 'pinch without an origin still projects the scale' , async ( ) => {
7586 const calls : Array < { method : string ; options : unknown } > = [ ] ;
0 commit comments