Skip to content

Commit

Permalink
Fix test compilation error
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkranzler5 committed Dec 14, 2023
1 parent 543d07b commit e7980dc
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import com.instacart.formula.android.FormulaAppCompatActivity
import com.instacart.formula.samples.R
import com.jakewharton.rxrelay3.PublishRelay
import org.junit.Before
import org.junit.Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import com.instacart.formula.android.FormulaAppCompatActivity
import com.instacart.formula.samples.R
import io.reactivex.rxjava3.core.Observable
import org.junit.Before
import org.junit.Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.google.common.truth.Truth.assertThat
import com.instacart.formula.android.Feature
import com.instacart.formula.android.ViewFactory
import com.instacart.formula.android.events.ActivityResult
import com.instacart.formula.samples.R
import com.instacart.formula.test.TestFragmentActivity
import com.instacart.formula.test.TestLifecycleKey
import io.reactivex.rxjava3.core.Observable
Expand All @@ -28,7 +29,7 @@ class FragmentAndroidEventTest {
configureActivity = {
initialContract = TestLifecycleKey()
},
contracts = {
contracts = {

bind<TestLifecycleKey> { _, _ ->
Feature(
Expand All @@ -52,14 +53,17 @@ class FragmentAndroidEventTest {

private val activityRule = ActivityScenarioRule(TestFragmentActivity::class.java)

@get:Rule val rule = RuleChain.outerRule(formulaRule).around(activityRule)
@get:Rule
val rule = RuleChain.outerRule(formulaRule).around(activityRule)
lateinit var scenario: ActivityScenario<TestFragmentActivity>

@Before fun setup() {
@Before
fun setup() {
scenario = activityRule.scenario
}

@Test fun `activity result`() {
@Test
fun `activity result`() {
FormulaAndroid.onActivityResult(scenario.activity(), 1, 2, null)

val expected = listOf(ActivityResult(1, 2, null))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import androidx.test.core.app.ActivityScenario
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import com.instacart.formula.android.FormulaFragment
import com.instacart.formula.android.ActivityStoreContext
import com.instacart.formula.android.FeatureFactory
import com.instacart.formula.android.FormulaFragment
import com.instacart.formula.android.FragmentKey
import com.instacart.formula.samples.R
import com.instacart.formula.test.TestFragmentActivity
import com.instacart.formula.test.TestKey
import com.instacart.formula.test.TestKeyWithId
import com.instacart.formula.test.TestFragmentActivity
import io.reactivex.rxjava3.core.Observable
import org.junit.Before
import org.junit.Rule
Expand All @@ -36,7 +37,7 @@ class FragmentLifecycleStateTest {
configureActivity = {
initialContract = TestKey()
},
contracts = {
contracts = {
bind(featureFactory<TestKey>(this@activity))
bind(featureFactory<TestKeyWithId>(this@activity))
}
Expand All @@ -57,18 +58,21 @@ class FragmentLifecycleStateTest {
scenario = activityRule.scenario
}

@Test fun `is fragment started`() {
@Test
fun `is fragment started`() {
val events = selectStartedEvents(TestKey())
assertThat(events).containsExactly(false, true).inOrder()
}

@Test fun `is fragment resumed`() {
@Test
fun `is fragment resumed`() {
val events = selectResumedEvents(TestKey())
assertThat(events).containsExactly(false, true).inOrder()
}

@LooperMode(LooperMode.Mode.LEGACY)
@Test fun `navigate forward`() {
@Test
fun `navigate forward`() {
navigateToTaskDetail()

val contract = TestKey()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.google.common.truth.Truth.assertThat
import com.instacart.formula.android.Feature
import com.instacart.formula.android.FeatureFactory
import com.instacart.formula.android.ViewFactory
import com.instacart.formula.samples.R
import com.instacart.formula.test.TestFragmentActivity
import com.instacart.formula.test.TestFragmentLifecycleCallback
import com.instacart.formula.test.TestLifecycleKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.instacart.formula.android.Feature
import com.instacart.formula.android.FeatureFactory
import com.instacart.formula.android.FragmentKey
import com.instacart.formula.android.ViewFactory
import com.instacart.formula.samples.R
import com.instacart.formula.test.TestFragmentActivity
import io.reactivex.rxjava3.core.Observable

Expand Down

0 comments on commit e7980dc

Please sign in to comment.