use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class CommentsViewModelTest method testCommentsViewModel_postCommentFlow.
@Test
public void testCommentsViewModel_postCommentFlow() {
final CommentsViewModel vm = new CommentsViewModel(environment());
final Project project = ProjectFactory.backedProject();
final TestSubscriber<Void> showCommentPostedToastTest = new TestSubscriber<>();
vm.outputs.showCommentPostedToast().subscribe(showCommentPostedToastTest);
final TestSubscriber<Void> dismissCommentDialogTest = new TestSubscriber<>();
vm.outputs.dismissCommentDialog().subscribe(dismissCommentDialogTest);
final TestSubscriber<Boolean> postButtonIsEnabledTest = new TestSubscriber<>();
vm.outputs.enablePostButton().subscribe(postButtonIsEnabledTest);
final TestSubscriber<Boolean> showCommentButtonTest = new TestSubscriber<>();
vm.outputs.showCommentButton().subscribe(showCommentButtonTest);
final TestSubscriber<Pair<Project, Boolean>> showCommentDialogTest = new TestSubscriber<>();
vm.outputs.showCommentDialog().subscribe(showCommentDialogTest);
// Start the view model with a project.
vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
koalaTest.assertValues(KoalaEvent.VIEWED_COMMENTS, KoalaEvent.PROJECT_COMMENT_VIEW);
// Comment button should be shown.
showCommentButtonTest.assertValue(true);
// Click comment button. Comment dialog should be shown.
vm.inputs.commentButtonClicked();
showCommentDialogTest.assertValue(Pair.create(project, true));
// Write a comment. The post button should be enabled with valid comment body.
vm.inputs.commentBodyChanged("");
postButtonIsEnabledTest.assertValues(false);
vm.inputs.commentBodyChanged("Some comment");
postButtonIsEnabledTest.assertValues(false, true);
// Post comment. Dialog should be dismissed.
vm.inputs.postCommentClicked();
dismissCommentDialogTest.assertValueCount(1);
// Comment posted toast should be shown.
showCommentPostedToastTest.assertValueCount(1);
// A koala event for commenting should be tracked.
koalaTest.assertValues(KoalaEvent.VIEWED_COMMENTS, KoalaEvent.PROJECT_COMMENT_VIEW, KoalaEvent.POSTED_COMMENT, KoalaEvent.PROJECT_COMMENT_CREATE);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class ProjectFactory method backedProjectWithRewardLimited.
@NonNull
public static Project backedProjectWithRewardLimited() {
final Project project = project();
final Reward reward = RewardFactory.limited();
final Backing backing = Backing.builder().amount(10.0f).backerId(IdFactory.id()).id(IdFactory.id()).sequence(1).reward(reward).rewardId(reward.id()).pledgedAt(DateTime.now()).projectCountry(project.country()).projectId(project.id()).shippingAmount(0.0f).status(Backing.STATUS_PLEDGED).build();
return project.toBuilder().backing(backing).isBacking(true).build();
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class UpdateFactory method update.
public static Update update() {
final Project project = ProjectFactory.project();
final String updatesUrl = "https://www.kck.str/projects/" + project.creator().param() + "/" + project.param() + "/posts";
final Update.Urls.Web web = Update.Urls.Web.builder().update(updatesUrl + "id").likes(updatesUrl + "/likes").build();
return Update.builder().body("Update body").id(1234).projectId(5678).sequence(11111).title("First update").urls(Update.Urls.builder().web(web).build()).build();
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class BackingUtilsTest method testIsBacked.
@Test
public void testIsBacked() {
final Project backedProject = ProjectFactory.backedProject();
assertTrue(BackingUtils.isBacked(backedProject, backedProject.backing().reward()));
assertFalse(BackingUtils.isBacked(backedProject, RewardFactory.reward()));
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RefTagUtilsTest method testCookieNameForProject.
@Test
public void testCookieNameForProject() {
final Project project = ProjectFactory.project();
assertEquals("ref_" + String.valueOf(project.id()), RefTagUtils.cookieNameForProject(project));
}
Aggregations