RNInstabugRepliesModule extends ReactContextBaseJavaModule { @ReactMethod public void setOnNewReplyReceivedHandler(final Callback onNewReplyReceivedCallback) { MainThreadHandler.runOnMainThread(new Runnable() { @Override public void run() { try { Runnable onNewReplyReceivedRunnable = new Runnable() { @Override public void run() { InstabugUtil.sendEvent(getReactApplicationContext(), Constants.IBG_ON_NEW_REPLY_RECEIVED_CALLBACK, null); } }; Replies.setOnNewReplyReceivedCallback(onNewReplyReceivedRunnable); } catch (java.lang.Exception exception) { exception.printStackTrace(); } } }); } RNInstabugRepliesModule(ReactApplicationContext reactApplicationContext); @Nonnull @Override String getName(); @ReactMethod void setEnabled(final boolean isEnabled); @ReactMethod void hasChats(final Callback callback); @ReactMethod void show(); @ReactMethod void setInAppNotificationSound(final boolean shouldPlaySound); @ReactMethod void getUnreadRepliesCount(final Callback messageCountCallback); @ReactMethod void setInAppNotificationEnabled(final boolean isChatNotificationEnable); @ReactMethod void setOnNewReplyReceivedHandler(final Callback onNewReplyReceivedCallback);  }
@Test public void given$setOnNewReplyReceivedHandler_whenQuery_thenShouldSetNativeCallback() { PowerMockito.mockStatic(Replies.class); Callback callback = mock(Callback.class); rnModule.setOnNewReplyReceivedHandler(callback); PowerMockito.verifyStatic(VerificationModeFactory.times(1)); Replies.setOnNewReplyReceivedCallback(any(Runnable.class)); }