@@ -109,6 +109,33 @@ describe('Instabug Module', () => {
109
109
} ) ;
110
110
} ) ;
111
111
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
+
112
139
it ( 'onNavigationStateChange should not call the native method reportScreenChange if screen is the same' , ( done ) => {
113
140
InstabugUtils . getActiveRouteName = jest . fn ( ) . mockImplementation ( ( screenName ) => screenName ) ;
114
141
@@ -122,7 +149,20 @@ describe('Instabug Module', () => {
122
149
} , 1500 ) ;
123
150
} ) ;
124
151
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 ( ) => {
126
166
InstabugUtils . getActiveRouteName = jest . fn ( ) . mockImplementation ( ( screenName ) => screenName ) ;
127
167
128
168
// sets _currentScreen and waits for 1s as _currentScreen is null
@@ -150,6 +190,31 @@ describe('Instabug Module', () => {
150
190
} ) ;
151
191
} ) ;
152
192
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
+
153
218
it ( 'onStateChange should call the native method reportScreenChange immediately if _currentScreen is set' , async ( ) => {
154
219
// sets _currentScreen and waits for 1s as _currentScreen is null
155
220
const state = { routes : [ { name : 'ScreenName' } ] , index : 0 } ;
@@ -195,6 +260,31 @@ describe('Instabug Module', () => {
195
260
} ) ;
196
261
} ) ;
197
262
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
+
198
288
it ( 'should call the native method setUserData' , ( ) => {
199
289
const userData = 'userData' ;
200
290
Instabug . setUserData ( userData ) ;
0 commit comments