RNInstabugRepliesModule extends ReactContextBaseJavaModule { @ReactMethod public void setEnabled(final boolean isEnabled) { MainThreadHandler.runOnMainThread(new Runnable() { @Override public void run() { try { if (isEnabled) { Replies.setState(Feature.State.ENABLED); } else { Replies.setState(Feature.State.DISABLED); } } catch (Exception e) { e.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 givenFalse$setEnabled_whenQuery_thenShouldCallNativeApiWithDisabled() { PowerMockito.mockStatic(Replies.class); rnModule.setEnabled(false); PowerMockito.verifyStatic(VerificationModeFactory.times(1)); Replies.setState(Feature.State.DISABLED); }
@Test public void givenTrue$setEnabled_whenQuery_thenShouldCallNativeApiWithEnabled() { PowerMockito.mockStatic(Replies.class); rnModule.setEnabled(true); PowerMockito.verifyStatic(VerificationModeFactory.times(1)); Replies.setState(Feature.State.ENABLED); }