use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class ThanksViewModelTest method testThanksViewModel_dontShowGamesNewsletterDialogIfRootCategoryIsNotGames.
@Test
public void testThanksViewModel_dontShowGamesNewsletterDialogIfRootCategoryIsNotGames() {
final MockBooleanPreference hasSeenGamesNewsletterPreference = new MockBooleanPreference(false);
final User user = UserFactory.user().toBuilder().gamesNewsletter(false).build();
final CurrentUserType currentUser = new MockCurrentUser(user);
final Environment environment = environment().toBuilder().currentUser(currentUser).hasSeenGamesNewsletterPreference(hasSeenGamesNewsletterPreference).build();
setUpEnvironment(environment);
final Project project = ProjectFactory.project().toBuilder().category(CategoryFactory.ceramicsCategory()).build();
this.vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
this.showGamesNewsletterDialogTest.assertValueCount(0);
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class ThanksViewModelTest method testThanksViewModel_whenFeatureFlagOn_shouldEmitProjectPage.
@Test
public void testThanksViewModel_whenFeatureFlagOn_shouldEmitProjectPage() {
final MockCurrentUser user = new MockCurrentUser();
final MockExperimentsClientType mockExperimentsClientType = new MockExperimentsClientType() {
@Override
public boolean isFeatureEnabled(@NotNull final OptimizelyFeature.Key feature) {
return true;
}
};
final Environment environment = environment().toBuilder().currentUser(user).optimizely(mockExperimentsClientType).build();
setUpEnvironment(environment);
final Project project = ProjectFactory.project();
final CheckoutData checkoutData = CheckoutDataFactory.Companion.checkoutData(3L, 20.0, 30.0);
final PledgeData pledgeData = PledgeData.Companion.with(PledgeFlowContext.NEW_PLEDGE, ProjectDataFactory.Companion.project(project), RewardFactory.reward(), Collections.emptyList(), null);
final Intent intent = new Intent().putExtra(IntentKey.CHECKOUT_DATA, checkoutData).putExtra(IntentKey.PLEDGE_DATA, pledgeData).putExtra(IntentKey.PROJECT, project);
this.vm.intent(intent);
this.vm.inputs.projectCardViewHolderClicked(project);
final Pair<Project, RefTag> projectPageParams = this.startProjectTest.getOnNextEvents().get(0);
assertEquals(projectPageParams.first, project);
assertEquals(projectPageParams.second, RefTag.thanks());
this.segmentTrack.assertValues(EventName.PAGE_VIEWED.getEventName(), EventName.CTA_CLICKED.getEventName());
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class UpdateViewModelTest method testUpdateViewModel_whenFeatureFlagOn_shouldEmitProjectPage.
@Test
public void testUpdateViewModel_whenFeatureFlagOn_shouldEmitProjectPage() {
final MockCurrentUser user = new MockCurrentUser();
final MockExperimentsClientType mockExperimentsClientType = new MockExperimentsClientType() {
@Override
public boolean isFeatureEnabled(@NotNull final OptimizelyFeature.Key feature) {
return true;
}
};
final Environment environment = environment().toBuilder().currentUser(user).optimizely(mockExperimentsClientType).build();
final UpdateViewModel.ViewModel vm = new UpdateViewModel.ViewModel(environment);
final TestSubscriber<Pair<Uri, RefTag>> startProjectActivity = new TestSubscriber<>();
vm.outputs.startProjectActivity().subscribe(startProjectActivity);
// Start the intent with a project and update.
vm.intent(this.defaultIntent);
final String url = "https://www.kickstarter.com/projects/smithsonian/smithsonian-anthology-of-hip-hop-and-rap";
final Request projectRequest = new Request.Builder().url(url).build();
vm.inputs.goToProjectRequest(projectRequest);
startProjectActivity.assertValueCount(1);
assertEquals(startProjectActivity.getOnNextEvents().get(0).first, Uri.parse(url));
assertEquals(startProjectActivity.getOnNextEvents().get(0).second, RefTag.update());
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class MessagesViewModelTest method testToolbarIsExpanded_NoMessages.
@Test
public void testToolbarIsExpanded_NoMessages() {
final Backing backing = BackingFactory.backing();
final MessageThreadEnvelope envelope = MessageThreadEnvelopeFactory.messageThreadEnvelope().toBuilder().messages(null).build();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<MessageThreadEnvelope> fetchMessagesForBacking(@NonNull final Backing backing) {
return Observable.just(envelope);
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).currentUser(new MockCurrentUser(UserFactory.user())).build());
// Start the view model with a backing and project.
this.vm.intent(backerModalContextIntent(backing, ProjectFactory.project()));
this.vm.inputs.messageEditTextIsFocused(true);
// Toolbar stays expanded when keyboard opens and no messages.
this.toolbarIsExpanded.assertNoValues();
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class MessagesViewModelTest method testViewMessages_FromPush.
@Test
public void testViewMessages_FromPush() {
setUpEnvironment(environment().toBuilder().currentUser(new MockCurrentUser(UserFactory.user())).build());
this.vm.intent(pushContextIntent());
this.backButtonIsGone.assertValues(true);
this.closeButtonIsGone.assertValues(false);
this.viewPledgeButtonIsGone.assertValues(false);
}
Aggregations