RNInstabugSurveysModule extends ReactContextBaseJavaModule { @ReactMethod public void setOnDismissHandler(final Callback handler) { MainThreadHandler.runOnMainThread(new Runnable() { @Override public void run() { Surveys.setOnDismissCallback(new OnDismissCallback() { @Override public void onDismiss() { InstabugUtil.sendEvent(getReactApplicationContext(), Constants.IBG_ON_DISMISS_SURVEY_HANDLER, null); } }); } }); } 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 given$setOnDismissSurveyHandler_whenQuery_thenShouldSetNativeCallback() { try { PowerMockito.mockStatic(Surveys.class); PowerMockito.mockStatic(InstabugUtil.class); PowerMockito.doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) { ((OnDismissCallback) invocation.getArguments()[0]).onDismiss(); return null; } }).when(Surveys.class, "setOnDismissCallback", Matchers.anyObject()); surveysModule.setOnDismissHandler(null); PowerMockito.verifyStatic(VerificationModeFactory.times(1)); InstabugUtil.sendEvent(any(ReactApplicationContext.class), eq(Constants.IBG_ON_DISMISS_SURVEY_HANDLER), Matchers.isNull(WritableMap.class)); } catch (Exception e) { e.printStackTrace(); } }