From 71e10ec41628c7f4aa0a9c52e44db7f375798bc9 Mon Sep 17 00:00:00 2001 From: Laimonas Turauskas Date: Tue, 17 Sep 2024 10:22:10 -0400 Subject: [PATCH] More tests for formula-android. --- .../instacart/formula/android/ActivityConfigurator.kt | 2 +- .../formula/android/internal/ActivityStoreFactory.kt | 2 +- .../formula/android/ActivityStoreFactoryTest.kt | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/formula-android/src/main/java/com/instacart/formula/android/ActivityConfigurator.kt b/formula-android/src/main/java/com/instacart/formula/android/ActivityConfigurator.kt index 40ea1c766..5663c3f0b 100644 --- a/formula-android/src/main/java/com/instacart/formula/android/ActivityConfigurator.kt +++ b/formula-android/src/main/java/com/instacart/formula/android/ActivityConfigurator.kt @@ -8,7 +8,7 @@ import kotlin.reflect.KClass */ class ActivityConfigurator { internal class Binding( - val init: ActivityStoreContext.() -> ActivityStore? + val init: ActivityStoreContext.() -> ActivityStore ) internal val bindings = mutableMapOf, Binding<*>>() diff --git a/formula-android/src/main/java/com/instacart/formula/android/internal/ActivityStoreFactory.kt b/formula-android/src/main/java/com/instacart/formula/android/internal/ActivityStoreFactory.kt index 27129ce4e..e2f88b34b 100644 --- a/formula-android/src/main/java/com/instacart/formula/android/internal/ActivityStoreFactory.kt +++ b/formula-android/src/main/java/com/instacart/formula/android/internal/ActivityStoreFactory.kt @@ -24,7 +24,7 @@ internal class ActivityStoreFactory internal constructor( ?: return null val activityDelegate = ActivityStoreContextImpl() - return initializer.init.invoke(activityDelegate)?.let { store -> + return initializer.init.invoke(activityDelegate).let { store -> ActivityManager( environment = environment, delegate = activityDelegate, diff --git a/formula-android/src/test/java/com/instacart/formula/android/ActivityStoreFactoryTest.kt b/formula-android/src/test/java/com/instacart/formula/android/ActivityStoreFactoryTest.kt index 13414be72..a1b78726a 100644 --- a/formula-android/src/test/java/com/instacart/formula/android/ActivityStoreFactoryTest.kt +++ b/formula-android/src/test/java/com/instacart/formula/android/ActivityStoreFactoryTest.kt @@ -26,4 +26,14 @@ class ActivityStoreFactoryTest { val store = factory.init(mock())!! assertThat(store.stateSubscription.isDisposed).isFalse() } + + @Test fun `returns null if no binding for activity is found`() { + val factory = ActivityStoreFactory( + environment = FragmentEnvironment(), + activities = {} + ) + + val store = factory.init(mock()) + assertThat(store).isNull() + } }