RNInstabugFeatureRequestsModule extends ReactContextBaseJavaModule { @ReactMethod public void setEnabled(final boolean isEnabled) { MainThreadHandler.runOnMainThread(new Runnable() { @Override public void run() { try { if (isEnabled) { FeatureRequests.setState(Feature.State.ENABLED); } else { FeatureRequests.setState(Feature.State.DISABLED); } } catch (Exception e) { e.printStackTrace(); } } }); } RNInstabugFeatureRequestsModule(ReactApplicationContext reactApplicationContext); @Nonnull @Override String getName(); @SuppressLint("WrongConstant") @ReactMethod void setEmailFieldRequiredForFeatureRequests(final boolean isEmailRequired, final ReadableArray actionTypes); @ReactMethod void show(); @ReactMethod void setEnabled(final boolean isEnabled);  }
@Test public void givenFalse$setEnabled_whenQuery_thenShouldCallNativeApiWithDisabled() throws Exception{ PowerMockito.mockStatic(FeatureRequests.class); featureRequestsModule.setEnabled(false); PowerMockito.verifyStatic(VerificationModeFactory.times(1)); FeatureRequests.setState(Feature.State.DISABLED); }
@Test public void givenTrue$setEnabled_whenQuery_thenShouldCallNativeApiWithEnabled() { PowerMockito.mockStatic(FeatureRequests.class); featureRequestsModule.setEnabled(true); PowerMockito.verifyStatic(VerificationModeFactory.times(1)); FeatureRequests.setState(Feature.State.ENABLED); }