RNInstabugSurveysModule extends ReactContextBaseJavaModule { @ReactMethod public void hasRespondedToSurvey(final String surveyToken, final Callback hasRespondedCallback) { MainThreadHandler.runOnMainThread(new Runnable() { @Override public void run() { boolean hasResponded; try { hasResponded = Surveys.hasRespondToSurvey(surveyToken); hasRespondedCallback.invoke(hasResponded); } catch (Exception e) { e.printStackTrace(); } } }); } RNInstabugSurveysModule(ReactApplicationContext reactContext); @Nonnull @Override String getName(); @ReactMethod void hasRespondedToSurvey(final String surveyToken, final Callback hasRespondedCallback); @ReactMethod void showSurvey(final String surveyToken); @ReactMethod void showSurveysIfAvailable(); @ReactMethod void setEnabled(final boolean isEnabled); @ReactMethod void setOnShowHandler(final Callback handler); @ReactMethod void setOnDismissHandler(final Callback handler); @ReactMethod void setThresholdForReshowingSurveyAfterDismiss(final int sessionsCount, final int daysCount); @ReactMethod void getAvailableSurveys(final Callback availableSurveysCallback); @ReactMethod void setAutoShowingEnabled(final boolean autoShowingSurveysEnabled); @ReactMethod void setShouldShowWelcomeScreen(final boolean shouldShow);  }
@Test public void givenBoolean$hasRespondedToSurvey_whenQuery_thenShouldCallNativeApiAndInvokeCallback() { PowerMockito.mockStatic(Surveys.class); Callback callback = mock(Callback.class); surveysModule.hasRespondedToSurvey("123", callback); PowerMockito.verifyStatic(VerificationModeFactory.times(1)); Surveys.hasRespondToSurvey("123"); verify(callback).invoke(any()); }