Search in sources :

Example 1 with SurveyResponse

use of com.kickstarter.models.SurveyResponse in project android-oss by kickstarter.

the class SurveyHolderViewModelTest method testCreatorNameEmits.

@Test
public void testCreatorNameEmits() {
    final SurveyResponse surveyResponse = SurveyResponseFactory.surveyResponse();
    setUpEnvironment(environment());
    this.vm.inputs.configureWith(surveyResponse);
    this.creatorNameTextViewText.assertValues(surveyResponse.project().creator().name());
}
Also used : SurveyResponse(com.kickstarter.models.SurveyResponse) Test(org.junit.Test)

Example 2 with SurveyResponse

use of com.kickstarter.models.SurveyResponse in project android-oss by kickstarter.

the class SurveyResponseViewModelTest method testWebViewUrl.

@Test
public void testWebViewUrl() {
    final SurveyResponse surveyResponse = SurveyResponseFactory.surveyResponse();
    setUpEnvironment(environment());
    this.vm.intent(new Intent().putExtra(IntentKey.SURVEY_RESPONSE, surveyResponse));
    this.webViewUrl.assertValues(surveyResponse.urls().web().survey());
}
Also used : SurveyResponse(com.kickstarter.models.SurveyResponse) Intent(android.content.Intent) Test(org.junit.Test)

Example 3 with SurveyResponse

use of com.kickstarter.models.SurveyResponse in project android-oss by kickstarter.

the class SurveyResponseViewModelTest method testSubmitSuccessful_NullTag_ShowConfirmationDialog.

@Test
public void testSubmitSuccessful_NullTag_ShowConfirmationDialog() {
    final String surveyUrl = "https://kck.str/projects/param/heyo/surveys/123";
    final SurveyResponse.Urls urlsEnvelope = SurveyResponse.Urls.builder().web(SurveyResponse.Urls.Web.builder().survey(surveyUrl).build()).build();
    final SurveyResponse surveyResponse = SurveyResponseFactory.surveyResponse().toBuilder().urls(urlsEnvelope).build();
    final Request projectSurveyRequest = new Request.Builder().url(surveyUrl).build();
    final Request projectRequest = new Request.Builder().url("https://kck.str/projects/param/heyo").build();
    setUpEnvironment(environment());
    this.vm.intent(new Intent().putExtra(IntentKey.SURVEY_RESPONSE, surveyResponse));
    // Survey loads. Successful submit redirects to project uri.
    this.vm.inputs.projectSurveyUriRequest(projectSurveyRequest);
    this.vm.inputs.projectUriRequest(projectRequest);
    // Success confirmation dialog is shown.
    this.showConfirmationDialog.assertValueCount(1);
}
Also used : SurveyResponse(com.kickstarter.models.SurveyResponse) Request(okhttp3.Request) Intent(android.content.Intent) Test(org.junit.Test)

Example 4 with SurveyResponse

use of com.kickstarter.models.SurveyResponse in project android-oss by kickstarter.

the class SurveyResponseViewModelTest method testSubmitSuccessful_Redirect_ShowConfirmationDialog.

@Test
public void testSubmitSuccessful_Redirect_ShowConfirmationDialog() {
    final String surveyUrl = "https://kck.str/projects/param/heyo/surveys/123";
    final SurveyResponse.Urls urlsEnvelope = SurveyResponse.Urls.builder().web(SurveyResponse.Urls.Web.builder().survey(surveyUrl).build()).build();
    final SurveyResponse surveyResponse = SurveyResponseFactory.surveyResponse().toBuilder().urls(urlsEnvelope).build();
    final Request projectSurveyRequest = new Request.Builder().url(surveyUrl).build();
    final Request projectRequest = new Request.Builder().url("https://kck.str/projects/param/heyo").tag(projectSurveyRequest).build();
    setUpEnvironment(environment());
    this.vm.intent(new Intent().putExtra(IntentKey.SURVEY_RESPONSE, surveyResponse));
    // Survey loads. Successful submit redirects to project uri.
    this.vm.inputs.projectSurveyUriRequest(projectSurveyRequest);
    this.vm.inputs.projectUriRequest(projectRequest);
    // Success confirmation dialog is shown.
    this.showConfirmationDialog.assertValueCount(1);
}
Also used : SurveyResponse(com.kickstarter.models.SurveyResponse) Request(okhttp3.Request) Intent(android.content.Intent) Test(org.junit.Test)

Example 5 with SurveyResponse

use of com.kickstarter.models.SurveyResponse in project android-oss by kickstarter.

the class ActivityFeedViewModelTest method testSurveys_LoggedOut.

@Test
public void testSurveys_LoggedOut() {
    final List<SurveyResponse> surveyResponses = Arrays.asList(SurveyResponseFactory.surveyResponse(), SurveyResponseFactory.surveyResponse());
    final MockApiClient apiClient = new MockApiClient() {

        @Override
        @NonNull
        public Observable<List<SurveyResponse>> fetchUnansweredSurveys() {
            return Observable.just(surveyResponses);
        }
    };
    final CurrentUserType currentUser = new MockCurrentUser();
    currentUser.logout();
    final Environment environment = this.environment().toBuilder().apiClient(apiClient).currentUser(currentUser).build();
    setUpEnvironment(environment);
    this.vm.inputs.resume();
    this.surveys.assertNoValues();
}
Also used : MockApiClient(com.kickstarter.mock.services.MockApiClient) SurveyResponse(com.kickstarter.models.SurveyResponse) Environment(com.kickstarter.libs.Environment) List(java.util.List) CurrentUserType(com.kickstarter.libs.CurrentUserType) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Aggregations

SurveyResponse (com.kickstarter.models.SurveyResponse)9 Test (org.junit.Test)9 Intent (android.content.Intent)3 List (java.util.List)2 Request (okhttp3.Request)2 CurrentUserType (com.kickstarter.libs.CurrentUserType)1 Environment (com.kickstarter.libs.Environment)1 MockCurrentUser (com.kickstarter.libs.MockCurrentUser)1 MockApiClient (com.kickstarter.mock.services.MockApiClient)1 Activity (com.kickstarter.models.Activity)1 ErroredBacking (com.kickstarter.models.ErroredBacking)1