RNInstabugRepliesModule extends ReactContextBaseJavaModule { @ReactMethod public void getUnreadRepliesCount(final Callback messageCountCallback) { MainThreadHandler.runOnMainThread(new Runnable() { @Override public void run() { int unreadMessages = 0; try { unreadMessages = Replies.getUnreadRepliesCount(); } catch (Exception e) { e.printStackTrace(); } messageCountCallback.invoke(unreadMessages); } }); } 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 givenCallback$getUnreadRepliesCount_whenQuery_thenShouldCallNativeApiAndInvokeCallback() { PowerMockito.mockStatic(Replies.class); Callback callback = mock(Callback.class); rnModule.getUnreadRepliesCount(callback); PowerMockito.verifyStatic(VerificationModeFactory.times(1)); Replies.getUnreadRepliesCount(); verify(callback).invoke(any()); }