Search in sources :

Example 6 with ProjectDashboardData

use of com.kickstarter.ui.adapters.data.ProjectDashboardData in project android-oss by kickstarter.

the class CreatorDashboardHeaderHolderViewModelTest method testOtherProjectsButtonIsGone_whenCurrentUserIsMemberOfManyProjects_viewingSingleProject.

@Test
public void testOtherProjectsButtonIsGone_whenCurrentUserIsMemberOfManyProjects_viewingSingleProject() {
    final CurrentUserType collaborator = new MockCurrentUser(UserFactory.collaborator());
    setUpEnvironment(environment().toBuilder().currentUser(collaborator).build());
    this.vm.inputs.configureWith(new ProjectDashboardData(ProjectFactory.project(), ProjectStatsEnvelopeFactory.projectStatsEnvelope(), true));
    this.otherProjectsButtonIsGone.assertValue(true);
}
Also used : CurrentUserType(com.kickstarter.libs.CurrentUserType) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) ProjectDashboardData(com.kickstarter.ui.adapters.data.ProjectDashboardData) Test(org.junit.Test)

Example 7 with ProjectDashboardData

use of com.kickstarter.ui.adapters.data.ProjectDashboardData in project android-oss by kickstarter.

the class CreatorDashboardHeaderHolderViewModelTest method testProjectNameTextViewText.

@Test
public void testProjectNameTextViewText() {
    final Project project = ProjectFactory.project().toBuilder().name("somebody once told me").build();
    final ProjectStatsEnvelope projectStatsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope();
    setUpEnvironment(environment());
    this.vm.inputs.configureWith(new ProjectDashboardData(project, projectStatsEnvelope, false));
    this.projectNameTextViewText.assertValue("somebody once told me");
}
Also used : Project(com.kickstarter.models.Project) ProjectStatsEnvelope(com.kickstarter.services.apiresponses.ProjectStatsEnvelope) ProjectDashboardData(com.kickstarter.ui.adapters.data.ProjectDashboardData) Test(org.junit.Test)

Example 8 with ProjectDashboardData

use of com.kickstarter.ui.adapters.data.ProjectDashboardData in project android-oss by kickstarter.

the class CreatorDashboardHeaderHolderViewModelTest method testStartProjectActivity_whenFeatureFlagOn_shouldEmitProjectPage.

@Test
public void testStartProjectActivity_whenFeatureFlagOn_shouldEmitProjectPage() {
    final Project project = ProjectFactory.project();
    final ProjectStatsEnvelope projectStatsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope();
    final CurrentUserType currentUser = new MockCurrentUser();
    final MockExperimentsClientType mockExperimentsClientType = new MockExperimentsClientType() {

        @Override
        public boolean isFeatureEnabled(@NotNull final OptimizelyFeature.Key feature) {
            return true;
        }
    };
    this.setUpEnvironment(environment().toBuilder().currentUser(currentUser).optimizely(mockExperimentsClientType).build());
    this.vm.inputs.configureWith(new ProjectDashboardData(project, projectStatsEnvelope, false));
    this.vm.inputs.projectButtonClicked();
    this.startProjectActivity.assertValueCount(1);
    assertEquals(this.startProjectActivity.getOnNextEvents().get(0).first, project);
    assertEquals(this.startProjectActivity.getOnNextEvents().get(0).second, RefTag.dashboard());
}
Also used : Project(com.kickstarter.models.Project) ProjectStatsEnvelope(com.kickstarter.services.apiresponses.ProjectStatsEnvelope) CurrentUserType(com.kickstarter.libs.CurrentUserType) MockExperimentsClientType(com.kickstarter.mock.MockExperimentsClientType) NotNull(org.jetbrains.annotations.NotNull) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) ProjectDashboardData(com.kickstarter.ui.adapters.data.ProjectDashboardData) Test(org.junit.Test)

Example 9 with ProjectDashboardData

use of com.kickstarter.ui.adapters.data.ProjectDashboardData in project android-oss by kickstarter.

the class CreatorDashboardHeaderHolderViewModelTest method testTimeRemainingText.

@Test
public void testTimeRemainingText() {
    setUpEnvironment(environment());
    DateTimeUtils.setCurrentMillisFixed(new DateTime().getMillis());
    final Project project = ProjectFactory.project().toBuilder().deadline(new DateTime().plusDays(10)).build();
    final ProjectStatsEnvelope projectStatsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope();
    final int deadlineVal = ProjectExt.deadlineCountdownValue(project);
    this.vm.inputs.configureWith(new ProjectDashboardData(project, projectStatsEnvelope, false));
    this.timeRemainingText.assertValue(NumberUtils.format(deadlineVal));
}
Also used : Project(com.kickstarter.models.Project) ProjectStatsEnvelope(com.kickstarter.services.apiresponses.ProjectStatsEnvelope) DateTime(org.joda.time.DateTime) ProjectDashboardData(com.kickstarter.ui.adapters.data.ProjectDashboardData) Test(org.junit.Test)

Example 10 with ProjectDashboardData

use of com.kickstarter.ui.adapters.data.ProjectDashboardData in project android-oss by kickstarter.

the class CreatorDashboardHeaderHolderViewModelTest method testViewProjectButtonIsGone_whenViewingSingleProject.

@Test
public void testViewProjectButtonIsGone_whenViewingSingleProject() {
    setUpEnvironment(environment());
    this.vm.inputs.configureWith(new ProjectDashboardData(ProjectFactory.project(), ProjectStatsEnvelopeFactory.projectStatsEnvelope(), true));
    this.viewProjectButtonIsGone.assertValue(true);
}
Also used : ProjectDashboardData(com.kickstarter.ui.adapters.data.ProjectDashboardData) Test(org.junit.Test)

Aggregations

ProjectDashboardData (com.kickstarter.ui.adapters.data.ProjectDashboardData)18 Test (org.junit.Test)15 Project (com.kickstarter.models.Project)13 ProjectStatsEnvelope (com.kickstarter.services.apiresponses.ProjectStatsEnvelope)11 CurrentUserType (com.kickstarter.libs.CurrentUserType)7 MockCurrentUser (com.kickstarter.libs.MockCurrentUser)7 User (com.kickstarter.models.User)4 Intent (android.content.Intent)3 NonNull (androidx.annotation.NonNull)3 MockApiClient (com.kickstarter.mock.services.MockApiClient)3 ProjectsEnvelope (com.kickstarter.services.apiresponses.ProjectsEnvelope)2 DateTime (org.joda.time.DateTime)2 MockExperimentsClientType (com.kickstarter.mock.MockExperimentsClientType)1 NotNull (org.jetbrains.annotations.NotNull)1