Search in sources :

Example 1 with DiscoveryParams

use of com.kickstarter.services.DiscoveryParams in project android-oss by kickstarter.

the class ThanksViewModelTest method testThanksViewModel_startDiscovery.

@Test
public void testThanksViewModel_startDiscovery() {
    final ThanksViewModel vm = new ThanksViewModel(environment());
    final Category category = CategoryFactory.category();
    final TestSubscriber<DiscoveryParams> startDiscoveryTest = new TestSubscriber<>();
    vm.outputs.startDiscovery().subscribe(startDiscoveryTest);
    vm.inputs.categoryClick(null, category);
    startDiscoveryTest.assertValues(DiscoveryParams.builder().category(category).build());
    koalaTest.assertValue("Checkout Finished Discover More");
}
Also used : Category(com.kickstarter.models.Category) TestSubscriber(rx.observers.TestSubscriber) DiscoveryParams(com.kickstarter.services.DiscoveryParams) Test(org.junit.Test)

Example 2 with DiscoveryParams

use of com.kickstarter.services.DiscoveryParams in project android-oss by kickstarter.

the class ProfileViewModelTest method testProfileViewModel_EmitsProjects.

@Test
public void testProfileViewModel_EmitsProjects() {
    final ApiClientType apiClient = new MockApiClient() {

        @Override
        @NonNull
        public Observable<DiscoverEnvelope> fetchProjects(@NonNull final DiscoveryParams params) {
            return Observable.just(DiscoverEnvelopeFactory.discoverEnvelope(Collections.singletonList(ProjectFactory.project())));
        }
    };
    final Environment env = environment().toBuilder().apiClient(apiClient).build();
    final ProfileViewModel.ViewModel vm = new ProfileViewModel.ViewModel(env);
    final TestSubscriber<List<Project>> projects = new TestSubscriber<>();
    vm.outputs.projects().subscribe(projects);
    koalaTest.assertValues(KoalaEvent.PROFILE_VIEW_MY, KoalaEvent.VIEWED_PROFILE);
    projects.assertValueCount(1);
}
Also used : DiscoverEnvelope(com.kickstarter.services.apiresponses.DiscoverEnvelope) MockApiClient(com.kickstarter.services.MockApiClient) NonNull(android.support.annotation.NonNull) Environment(com.kickstarter.libs.Environment) TestSubscriber(rx.observers.TestSubscriber) List(java.util.List) DiscoveryParams(com.kickstarter.services.DiscoveryParams) ApiClientType(com.kickstarter.services.ApiClientType) Test(org.junit.Test)

Example 3 with DiscoveryParams

use of com.kickstarter.services.DiscoveryParams in project android-oss by kickstarter.

the class DiscoveryIntentMapperTest method emitsFromDiscoveryCategoryUri.

@Test
public void emitsFromDiscoveryCategoryUri() {
    final Uri uri = Uri.parse("https://www.kickstarter.com/discover/categories/music");
    final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    final TestSubscriber<DiscoveryParams> resultTest = TestSubscriber.create();
    DiscoveryIntentMapper.params(intent, new MockApiClient()).subscribe(resultTest);
    resultTest.assertValueCount(1);
}
Also used : MockApiClient(com.kickstarter.services.MockApiClient) Intent(android.content.Intent) DiscoveryParams(com.kickstarter.services.DiscoveryParams) Uri(android.net.Uri) Test(org.junit.Test)

Example 4 with DiscoveryParams

use of com.kickstarter.services.DiscoveryParams in project android-oss by kickstarter.

the class DiscoveryIntentMapperTest method emitsFromDiscoveryLocationUri.

@Test
public void emitsFromDiscoveryLocationUri() {
    final Uri uri = Uri.parse("https://www.kickstarter.com/discover/places/sydney-au");
    final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    final TestSubscriber<DiscoveryParams> resultTest = TestSubscriber.create();
    DiscoveryIntentMapper.params(intent, new MockApiClient()).subscribe(resultTest);
    resultTest.assertValueCount(1);
}
Also used : MockApiClient(com.kickstarter.services.MockApiClient) Intent(android.content.Intent) DiscoveryParams(com.kickstarter.services.DiscoveryParams) Uri(android.net.Uri) Test(org.junit.Test)

Example 5 with DiscoveryParams

use of com.kickstarter.services.DiscoveryParams in project android-oss by kickstarter.

the class DiscoveryIntentMapperTest method emitsFromParamsExtra.

@Test
public void emitsFromParamsExtra() {
    final DiscoveryParams params = DiscoveryParams.builder().build();
    final Intent intent = new Intent().putExtra(IntentKey.DISCOVERY_PARAMS, params);
    final TestSubscriber<DiscoveryParams> resultTest = TestSubscriber.create();
    DiscoveryIntentMapper.params(intent, new MockApiClient()).subscribe(resultTest);
    resultTest.assertValues(params);
}
Also used : MockApiClient(com.kickstarter.services.MockApiClient) Intent(android.content.Intent) DiscoveryParams(com.kickstarter.services.DiscoveryParams) Test(org.junit.Test)

Aggregations

DiscoveryParams (com.kickstarter.services.DiscoveryParams)10 Test (org.junit.Test)9 Intent (android.content.Intent)7 MockApiClient (com.kickstarter.services.MockApiClient)6 Uri (android.net.Uri)4 TestSubscriber (rx.observers.TestSubscriber)4 Category (com.kickstarter.models.Category)3 NonNull (android.support.annotation.NonNull)2 Environment (com.kickstarter.libs.Environment)2 List (java.util.List)2 KSRobolectricTestCase (com.kickstarter.KSRobolectricTestCase)1 CategoryFactory (com.kickstarter.factories.CategoryFactory)1 InternalBuildEnvelopeFactory (com.kickstarter.factories.InternalBuildEnvelopeFactory)1 UserFactory (com.kickstarter.factories.UserFactory)1 MockCurrentUser (com.kickstarter.libs.MockCurrentUser)1 Transformers (com.kickstarter.libs.rx.transformers.Transformers)1 DiscoveryUtils (com.kickstarter.libs.utils.DiscoveryUtils)1 ListUtils (com.kickstarter.libs.utils.ListUtils)1 Project (com.kickstarter.models.Project)1 ApiClientType (com.kickstarter.services.ApiClientType)1