@@ -109,6 +109,33 @@ describe('Instabug Module', () => {
109109 } ) ;
110110 } ) ;
111111
112+ // eslint-disable-next-line jest/no-disabled-tests
113+ it . skip ( 'onNavigationStateChange should call the native method reportCurrentViewChange on Android Platform' , async ( ) => {
114+ Platform . OS = 'android' ;
115+ InstabugUtils . getActiveRouteName = jest . fn ( ) . mockImplementation ( ( screenName ) => screenName ) ;
116+
117+ // @ts -ignore
118+ Instabug . onNavigationStateChange ( 'home' , 'settings' ) ;
119+
120+ await waitForExpect ( ( ) => {
121+ expect ( NativeInstabug . reportCurrentViewChange ) . toBeCalledTimes ( 1 ) ;
122+ expect ( NativeInstabug . reportCurrentViewChange ) . toBeCalledWith ( 'settings' ) ;
123+ } ) ;
124+ } ) ;
125+
126+ // eslint-disable-next-line jest/no-disabled-tests
127+ it . skip ( 'onNavigationStateChange should not call the native method reportCurrentViewChange on iOS Platform' , async ( ) => {
128+ Platform . OS = 'ios' ;
129+ InstabugUtils . getActiveRouteName = jest . fn ( ) . mockImplementation ( ( screenName ) => screenName ) ;
130+
131+ // @ts -ignore
132+ Instabug . onNavigationStateChange ( 'home' , 'settings' ) ;
133+
134+ await waitForExpect ( ( ) => {
135+ expect ( NativeInstabug . reportCurrentViewChange ) . not . toBeCalled ( ) ;
136+ } ) ;
137+ } ) ;
138+
112139 it ( 'onNavigationStateChange should not call the native method reportScreenChange if screen is the same' , ( done ) => {
113140 InstabugUtils . getActiveRouteName = jest . fn ( ) . mockImplementation ( ( screenName ) => screenName ) ;
114141
@@ -122,7 +149,20 @@ describe('Instabug Module', () => {
122149 } , 1500 ) ;
123150 } ) ;
124151
125- it ( 'onNavigationStateChange should call the native method reportScreenChange immediatly if _currentScreen is set' , async ( ) => {
152+ it ( 'onNavigationStateChange should not call the native method reportCurrentViewChange if screen is the same' , ( done ) => {
153+ InstabugUtils . getActiveRouteName = jest . fn ( ) . mockImplementation ( ( screenName ) => screenName ) ;
154+
155+ // @ts -ignore
156+ Instabug . onNavigationStateChange ( 'home' , 'home' ) ;
157+
158+ // Wait for 1.5s as reportScreenChange is delayed by 1s
159+ setTimeout ( ( ) => {
160+ expect ( NativeInstabug . reportCurrentViewChange ) . not . toBeCalled ( ) ;
161+ done ( ) ;
162+ } , 1500 ) ;
163+ } ) ;
164+
165+ it ( 'onNavigationStateChange should call the native method reportScreenChange immediately if _currentScreen is set' , async ( ) => {
126166 InstabugUtils . getActiveRouteName = jest . fn ( ) . mockImplementation ( ( screenName ) => screenName ) ;
127167
128168 // sets _currentScreen and waits for 1s as _currentScreen is null
@@ -150,6 +190,31 @@ describe('Instabug Module', () => {
150190 } ) ;
151191 } ) ;
152192
193+ // eslint-disable-next-line jest/no-disabled-tests
194+ it . skip ( 'onStateChange should call the native method reportCurrentViewChange on Android Platform' , async ( ) => {
195+ Platform . OS = 'android' ;
196+ const state = { routes : [ { name : 'ScreenName' } ] , index : 0 } ;
197+ // @ts -ignore
198+ Instabug . onStateChange ( state ) ;
199+
200+ await waitForExpect ( ( ) => {
201+ expect ( NativeInstabug . reportCurrentViewChange ) . toBeCalledTimes ( 1 ) ;
202+ expect ( NativeInstabug . reportCurrentViewChange ) . toBeCalledWith ( 'ScreenName' ) ;
203+ } ) ;
204+ } ) ;
205+
206+ // eslint-disable-next-line jest/no-disabled-tests
207+ it . skip ( 'onStateChange should not call the native method reportCurrentViewChange on iOS Platform' , async ( ) => {
208+ Platform . OS = 'ios' ;
209+ const state = { routes : [ { name : 'ScreenName' } ] , index : 0 } ;
210+ // @ts -ignore
211+ Instabug . onStateChange ( state ) ;
212+
213+ await waitForExpect ( ( ) => {
214+ expect ( NativeInstabug . reportCurrentViewChange ) . not . toBeCalled ( ) ;
215+ } ) ;
216+ } ) ;
217+
153218 it ( 'onStateChange should call the native method reportScreenChange immediately if _currentScreen is set' , async ( ) => {
154219 // sets _currentScreen and waits for 1s as _currentScreen is null
155220 const state = { routes : [ { name : 'ScreenName' } ] , index : 0 } ;
@@ -195,6 +260,31 @@ describe('Instabug Module', () => {
195260 } ) ;
196261 } ) ;
197262
263+ it ( 'init should call reportCurrentViewChange on Android Platform' , async ( ) => {
264+ Platform . OS = 'android' ;
265+ Instabug . init ( {
266+ token : 'some-token' ,
267+ invocationEvents : [ InvocationEvent . none ] ,
268+ } ) ;
269+
270+ await waitForExpect ( ( ) => {
271+ expect ( NativeInstabug . reportCurrentViewChange ) . toBeCalledTimes ( 1 ) ;
272+ expect ( NativeInstabug . reportCurrentViewChange ) . toBeCalledWith ( 'Initial Screen' ) ;
273+ } ) ;
274+ } ) ;
275+
276+ it ( 'init should not call reportCurrentViewChange on ios Platform' , async ( ) => {
277+ Platform . OS = 'ios' ;
278+ Instabug . init ( {
279+ token : 'some-token' ,
280+ invocationEvents : [ InvocationEvent . none ] ,
281+ } ) ;
282+
283+ await waitForExpect ( ( ) => {
284+ expect ( NativeInstabug . reportCurrentViewChange ) . not . toBeCalled ( ) ;
285+ } ) ;
286+ } ) ;
287+
198288 it ( 'should call the native method setUserData' , ( ) => {
199289 const userData = 'userData' ;
200290 Instabug . setUserData ( userData ) ;
0 commit comments