use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class ThanksViewModelTest method testThanksViewModel_showRatingDialog.
@Test
public void testThanksViewModel_showRatingDialog() {
final MockBooleanPreference hasSeenAppRatingPreference = new MockBooleanPreference(false);
final MockBooleanPreference hasSeenGamesNewsletterPreference = new MockBooleanPreference(true);
final Environment environment = environment().toBuilder().hasSeenAppRatingPreference(hasSeenAppRatingPreference).hasSeenGamesNewsletterPreference(hasSeenGamesNewsletterPreference).build();
final ThanksViewModel vm = new ThanksViewModel(environment);
final TestSubscriber<Void> showRatingDialogTest = new TestSubscriber<>();
vm.outputs.showRatingDialog().subscribe(showRatingDialogTest);
final Project project = ProjectFactory.project();
vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
showRatingDialogTest.assertValueCount(1);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class ProjectUpdatesViewModelTest method testProjectUpdatesViewModel_ExternalLinkActivated.
@Test
public void testProjectUpdatesViewModel_ExternalLinkActivated() {
final ProjectUpdatesViewModel.ViewModel vm = new ProjectUpdatesViewModel.ViewModel(environment());
final Project project = ProjectFactory.project();
final TestSubscriber<String> webViewUrl = new TestSubscriber<>();
vm.outputs.webViewUrl().subscribe(webViewUrl);
vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
// Initial updates index url is loaded.
webViewUrl.assertValueCount(1);
// Activate an external link.
vm.inputs.externalLinkActivated();
// External url is not loaded in our web view.
webViewUrl.assertValueCount(1);
koalaTest.assertValues(KoalaEvent.VIEWED_UPDATES, KoalaEvent.OPENED_EXTERNAL_LINK);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class ProjectUpdatesViewModelTest method testProjectUpdatesViewModel_StartCommentsActivity.
@Test
public void testProjectUpdatesViewModel_StartCommentsActivity() {
final ProjectUpdatesViewModel.ViewModel vm = new ProjectUpdatesViewModel.ViewModel(environment());
final Project project = ProjectFactory.project();
final Request commentsRequest = new Request.Builder().url("https://kck.str/projects/param/param/posts/id/comments").build();
final TestSubscriber<Update> startCommentsActivity = new TestSubscriber<>();
vm.outputs.startCommentsActivity().subscribe(startCommentsActivity);
vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
vm.inputs.goToCommentsRequest(commentsRequest);
startCommentsActivity.assertValueCount(1);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class ProjectViewModelTest method testProjectViewModel_EmitsProjectWithStandardSetUp.
@Test
public void testProjectViewModel_EmitsProjectWithStandardSetUp() {
final Environment environment = environment();
environment.currentConfig().config(ConfigFactory.config());
final ProjectViewModel.ViewModel vm = new ProjectViewModel.ViewModel(environment);
final TestSubscriber<Project> projectTest = new TestSubscriber<>();
vm.outputs.projectAndUserCountry().map(pc -> pc.first).subscribe(projectTest);
final Project project = ProjectFactory.project();
vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
projectTest.assertValues(project, project);
koalaTest.assertValues(KoalaEvent.PROJECT_PAGE, KoalaEvent.VIEWED_PROJECT_PAGE);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class ProjectViewModelTest method testProjectViewModel_StartCommentsActivity.
@Test
public void testProjectViewModel_StartCommentsActivity() {
final ProjectViewModel.ViewModel vm = new ProjectViewModel.ViewModel(environment());
final Project project = ProjectFactory.project();
final TestSubscriber<Project> startCommentsActivity = new TestSubscriber<>();
vm.outputs.startCommentsActivity().subscribe(startCommentsActivity);
// Start the view model with a project.
vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
vm.inputs.commentsTextViewClicked();
startCommentsActivity.assertValues(project);
}
Aggregations