@@ -357,6 +357,8 @@ describe('Gesture', () => {
357357 globalEnvManager . switchToMainThread ( ) ;
358358 const rLynxChange = lynx . getNativeApp ( ) . callLepusMethod . mock . calls [ 0 ] ;
359359 globalThis [ rLynxChange [ 0 ] ] ( rLynxChange [ 1 ] ) ;
360+ const textElement = __root . __element_root . children [ 0 ] . children [ 0 ] ;
361+ expect ( elementTree . __GetGestureDetectorIds ( textElement ) ) . toEqual ( [ 3 ] ) ;
360362
361363 expect ( __root . __element_root ) . toMatchInlineSnapshot ( `
362364 <page
@@ -631,6 +633,7 @@ describe('Gesture', () => {
631633
632634describe ( 'Gesture in spread' , ( ) => {
633635 it ( 'normal gesture' , async function ( ) {
636+ const spySetGesture = vi . spyOn ( globalThis , '__SetGestureDetector' ) ;
634637 function Comp ( ) {
635638 const gesture = {
636639 id : 1 ,
@@ -696,6 +699,29 @@ describe('Gesture in spread', () => {
696699
697700 // Main Thread Render
698701 {
702+ const textElement = __root . __element_root . children [ 0 ] . children [ 0 ] ;
703+ expect ( spySetGesture ) . toHaveBeenCalledTimes ( 1 ) ;
704+ expect ( spySetGesture ) . toHaveBeenCalledWith (
705+ textElement ,
706+ 1 ,
707+ 0 ,
708+ {
709+ callbacks : [
710+ {
711+ name : 'onUpdate' ,
712+ callback : expect . objectContaining ( {
713+ _wkltId : 'bdd4:dd564:2' ,
714+ } ) ,
715+ } ,
716+ ] ,
717+ } ,
718+ {
719+ waitFor : [ ] ,
720+ simultaneous : [ ] ,
721+ continueWith : [ ] ,
722+ } ,
723+ ) ;
724+
699725 expect ( __root . __element_root ) . toMatchInlineSnapshot ( `
700726 <page
701727 cssId="default-entry-from-native:0"
@@ -737,6 +763,8 @@ describe('Gesture in spread', () => {
737763 }
738764 } ) ;
739765 it ( 'update gesture' , async function ( ) {
766+ const spySetGesture = vi . spyOn ( globalThis , '__SetGestureDetector' ) ;
767+ const spyRemoveGesture = vi . spyOn ( globalThis , '__RemoveGestureDetector' ) ;
740768 let _gesture = {
741769 id : 1 ,
742770 type : 0 ,
@@ -804,6 +832,8 @@ describe('Gesture in spread', () => {
804832 {
805833 globalEnvManager . switchToBackground ( ) ;
806834 lynx . getNativeApp ( ) . callLepusMethod . mockClear ( ) ;
835+ spySetGesture . mockClear ( ) ;
836+ spyRemoveGesture . mockClear ( ) ;
807837
808838 _gesture = {
809839 ..._gesture ,
@@ -815,6 +845,32 @@ describe('Gesture in spread', () => {
815845 globalEnvManager . switchToMainThread ( ) ;
816846 const rLynxChange = lynx . getNativeApp ( ) . callLepusMethod . mock . calls [ 0 ] ;
817847 globalThis [ rLynxChange [ 0 ] ] ( rLynxChange [ 1 ] ) ;
848+ const textElement = __root . __element_root . children [ 0 ] . children [ 0 ] ;
849+
850+ expect ( spySetGesture ) . toHaveBeenCalledTimes ( 1 ) ;
851+ expect ( spySetGesture ) . toHaveBeenCalledWith (
852+ textElement ,
853+ 2 ,
854+ 0 ,
855+ {
856+ callbacks : [
857+ {
858+ name : 'onUpdate' ,
859+ callback : expect . objectContaining ( {
860+ _wkltId : 'bdd4:dd564:2' ,
861+ } ) ,
862+ } ,
863+ ] ,
864+ } ,
865+ {
866+ waitFor : [ ] ,
867+ simultaneous : [ ] ,
868+ continueWith : [ ] ,
869+ } ,
870+ ) ;
871+ expect ( spyRemoveGesture ) . toHaveBeenCalledTimes ( 1 ) ;
872+ expect ( spyRemoveGesture ) . toHaveBeenCalledWith ( textElement , 1 ) ;
873+ expect ( elementTree . __GetGestureDetectorIds ( textElement ) ) . toEqual ( [ 2 ] ) ;
818874
819875 expect ( __root . __element_root ) . toMatchInlineSnapshot ( `
820876 <page
@@ -981,6 +1037,8 @@ describe('Gesture in spread', () => {
9811037 }
9821038 } ) ;
9831039 it ( 'remove gesture' , async function ( ) {
1040+ const spySetGesture = vi . spyOn ( globalThis , '__SetGestureDetector' ) ;
1041+ const spyRemoveGesture = vi . spyOn ( globalThis , '__RemoveGestureDetector' ) ;
9841042 let _gesture = {
9851043 id : 1 ,
9861044 type : 0 ,
@@ -1048,6 +1106,8 @@ describe('Gesture in spread', () => {
10481106 {
10491107 globalEnvManager . switchToBackground ( ) ;
10501108 lynx . getNativeApp ( ) . callLepusMethod . mockClear ( ) ;
1109+ spySetGesture . mockClear ( ) ;
1110+ spyRemoveGesture . mockClear ( ) ;
10511111
10521112 _gesture = undefined ;
10531113
@@ -1056,6 +1116,12 @@ describe('Gesture in spread', () => {
10561116 globalEnvManager . switchToMainThread ( ) ;
10571117 const rLynxChange = lynx . getNativeApp ( ) . callLepusMethod . mock . calls [ 0 ] ;
10581118 globalThis [ rLynxChange [ 0 ] ] ( rLynxChange [ 1 ] ) ;
1119+ const textElement = __root . __element_root . children [ 0 ] . children [ 0 ] ;
1120+ expect ( spySetGesture ) . not . toHaveBeenCalled ( ) ;
1121+ expect ( spyRemoveGesture ) . toHaveBeenCalledTimes ( 1 ) ;
1122+ expect ( spyRemoveGesture ) . toHaveBeenCalledWith ( textElement , 1 ) ;
1123+ expect ( elementTree . __GetGestureDetectorIds ( textElement ) ) . toEqual ( [ ] ) ;
1124+ expect ( textElement . props [ 'has-react-gesture' ] ) . toBeUndefined ( ) ;
10591125
10601126 expect ( __root . __element_root ) . toMatchInlineSnapshot ( `
10611127 <page
0 commit comments