File tree Expand file tree Collapse file tree 3 files changed +4
-25
lines changed Expand file tree Collapse file tree 3 files changed +4
-25
lines changed Original file line number Diff line number Diff line change @@ -35,9 +35,7 @@ export const App: React.FC = () => {
3535 } , [ ] ) ;
3636
3737 useEffect ( ( ) => {
38- const unregisterListener = Instabug . setNavigationListener ( navigationRef ) ;
39-
40- return unregisterListener ;
38+ Instabug . setNavigationListener ( navigationRef ) ;
4139 } , [ navigationRef ] ) ;
4240
4341 return (
Original file line number Diff line number Diff line change @@ -544,7 +544,7 @@ export const onStateChange = (state?: NavigationStateV5) => {
544544export const setNavigationListener = (
545545 navigationRef : NavigationContainerRefWithCurrent < ReactNavigation . RootParamList > ,
546546) => {
547- return navigationRef . addListener ( 'state' , ( ) => {
547+ navigationRef . addListener ( 'state' , ( ) => {
548548 onStateChange ( navigationRef . getRootState ( ) ) ;
549549 } ) ;
550550} ;
Original file line number Diff line number Diff line change @@ -238,39 +238,20 @@ describe('Instabug Module', () => {
238238 } ) ;
239239
240240 it ( 'setNavigationListener should call the onStateChange on a screen change' , async ( ) => {
241- const mockedState = { routes : [ { name : 'ScreenName' } ] , index : 0 } ;
242-
243241 const mockNavigationContainerRef = {
244242 current : null ,
245243 navigate : jest . fn ( ) ,
246244 reset : jest . fn ( ) ,
247245 goBack : jest . fn ( ) ,
248246 dispatch : jest . fn ( ) ,
249- getRootState : ( ) => mockedState ,
247+ getRootState : jest . fn ( ) ,
250248 canGoBack : jest . fn ( ) ,
251-
252- addListener : jest . fn ( ( event , callback ) => {
253- expect ( event ) . toBe ( 'state' ) ;
254- callback ( mockedState ) ;
255- return jest . fn ( ) ;
256- } ) ,
249+ addListener : jest . fn ( ) ,
257250 removeListener : jest . fn ( ) ,
258251 } as unknown as NavigationContainerRefWithCurrent < ReactNavigation . RootParamList > ;
259252
260- const onStateChangeMock = jest . fn ( ) ;
261-
262- jest . spyOn ( Instabug , 'onStateChange' ) . mockImplementation ( onStateChangeMock ) ;
263-
264253 Instabug . setNavigationListener ( mockNavigationContainerRef ) ;
265-
266254 expect ( mockNavigationContainerRef . addListener ) . toBeCalledTimes ( 1 ) ;
267- expect ( mockNavigationContainerRef . addListener ) . toHaveBeenCalledWith (
268- 'state' ,
269- expect . any ( Function ) ,
270- ) ;
271-
272- expect ( onStateChangeMock ) . toBeCalledTimes ( 1 ) ;
273- expect ( onStateChangeMock ) . toHaveBeenCalledWith ( mockNavigationContainerRef . getRootState ( ) ) ;
274255 } ) ;
275256
276257 it ( 'should call the native method init' , ( ) => {
You can’t perform that action at this time.
0 commit comments