use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class CreatorDashboardHeaderHolderViewModelTest method testStartMessagesActivity.
@Test
public void testStartMessagesActivity() {
final User creator = UserFactory.creator();
final CurrentUserType currentUser = new MockCurrentUser(creator);
final Project project = ProjectFactory.project().toBuilder().creator(creator).build();
setUpEnvironment(environment().toBuilder().currentUser(currentUser).build());
this.vm.inputs.configureWith(new ProjectDashboardData(project, ProjectStatsEnvelopeFactory.projectStatsEnvelope(), false));
this.vm.inputs.messagesButtonClicked();
this.startMessageThreadsActivity.assertValue(Pair.create(project, RefTag.dashboard()));
}
use of com.kickstarter.libs.MockCurrentUser 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);
}
use of com.kickstarter.libs.MockCurrentUser 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());
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class DiscoveryViewModelTest method testDrawerMenuIcon_whenUserHasNoUnreadMessagesOrUnseenActivityOrErroredBackings.
@Test
public void testDrawerMenuIcon_whenUserHasNoUnreadMessagesOrUnseenActivityOrErroredBackings() {
final MockCurrentUser currentUser = new MockCurrentUser(UserFactory.user());
this.vm = new DiscoveryViewModel.ViewModel(environment().toBuilder().currentUser(currentUser).build());
this.vm.getOutputs().drawerMenuIcon().subscribe(this.drawerMenuIcon);
this.drawerMenuIcon.assertValue(R.drawable.ic_menu);
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class DiscoveryViewModelTest method testDrawerData.
@Test
public void testDrawerData() {
final MockCurrentUser currentUser = new MockCurrentUser();
final Environment env = environment().toBuilder().currentUser(currentUser).build();
this.vm = new DiscoveryViewModel.ViewModel(env);
this.vm.getOutputs().navigationDrawerData().compose(Transformers.ignoreValues()).subscribe(this.navigationDrawerDataEmitted);
this.vm.getOutputs().drawerIsOpen().subscribe(this.drawerIsOpen);
// Initialize activity.
final Intent intent = new Intent(Intent.ACTION_MAIN);
this.vm.intent(intent);
// Initial MAGIC page selected.
this.vm.getInputs().discoveryPagerAdapterSetPrimaryPage(Mockito.mock(DiscoveryPagerAdapter.class), 0);
// Drawer data should emit. Drawer should be closed.
this.navigationDrawerDataEmitted.assertValueCount(1);
this.drawerIsOpen.assertNoValues();
this.segmentTrack.assertNoValues();
// Open drawer and click the top PWL filter.
this.vm.getInputs().openDrawer(true);
this.vm.getInputs().topFilterViewHolderRowClick(Mockito.mock(TopFilterViewHolder.class), NavigationDrawerData.Section.Row.builder().params(DiscoveryParams.builder().staffPicks(true).build()).build());
// Drawer data should emit. Drawer should open, then close upon selection.
this.navigationDrawerDataEmitted.assertValueCount(2);
this.drawerIsOpen.assertValues(true, false);
this.segmentTrack.assertValue(EventName.CTA_CLICKED.getEventName());
// Open drawer and click a child filter.
this.vm.getInputs().openDrawer(true);
this.vm.getInputs().childFilterViewHolderRowClick(Mockito.mock(ChildFilterViewHolder.class), NavigationDrawerData.Section.Row.builder().params(DiscoveryParams.builder().category(CategoryFactory.artCategory()).build()).build());
// Drawer data should emit. Drawer should open, then close upon selection.
this.navigationDrawerDataEmitted.assertValueCount(3);
this.drawerIsOpen.assertValues(true, false, true, false);
this.segmentTrack.assertValues(EventName.CTA_CLICKED.getEventName(), EventName.CTA_CLICKED.getEventName());
}
Aggregations