@@ -1049,6 +1049,55 @@ describe('Event responder: Press', () => {
10491049 ] ) ;
10501050 } ) ;
10511051
1052+ it ( 'no delay and "onPress*" events are correctly called with target change' , ( ) => {
1053+ let events = [ ] ;
1054+ const outerRef = React . createRef ( ) ;
1055+ const innerRef = React . createRef ( ) ;
1056+ const createEventHandler = msg => ( ) => {
1057+ events . push ( msg ) ;
1058+ } ;
1059+
1060+ const element = (
1061+ < div ref = { outerRef } >
1062+ < Press
1063+ onPress = { createEventHandler ( 'onPress' ) }
1064+ onPressChange = { createEventHandler ( 'onPressChange' ) }
1065+ onPressMove = { createEventHandler ( 'onPressMove' ) }
1066+ onPressStart = { createEventHandler ( 'onPressStart' ) }
1067+ onPressEnd = { createEventHandler ( 'onPressEnd' ) } >
1068+ < div ref = { innerRef } />
1069+ </ Press >
1070+ </ div >
1071+ ) ;
1072+
1073+ ReactDOM . render ( element , container ) ;
1074+
1075+ innerRef . current . getBoundingClientRect = getBoundingClientRectMock ;
1076+ innerRef . current . dispatchEvent ( createEvent ( 'pointerdown' ) ) ;
1077+ outerRef . current . dispatchEvent (
1078+ createEvent ( 'pointermove' , coordinatesOutside ) ,
1079+ ) ;
1080+ innerRef . current . dispatchEvent (
1081+ createEvent ( 'pointermove' , coordinatesInside ) ,
1082+ ) ;
1083+ innerRef . current . dispatchEvent (
1084+ createEvent ( 'pointerup' , coordinatesInside ) ,
1085+ ) ;
1086+ jest . runAllTimers ( ) ;
1087+
1088+ expect ( events ) . toEqual ( [
1089+ 'onPressStart' ,
1090+ 'onPressChange' ,
1091+ 'onPressEnd' ,
1092+ 'onPressChange' ,
1093+ 'onPressStart' ,
1094+ 'onPressChange' ,
1095+ 'onPressEnd' ,
1096+ 'onPressChange' ,
1097+ 'onPress' ,
1098+ ] ) ;
1099+ } ) ;
1100+
10521101 it ( 'delay and "onPressMove" is called before "onPress*" events' , ( ) => {
10531102 let events = [ ] ;
10541103 const ref = React . createRef ( ) ;
0 commit comments