Skip to content

Commit

Permalink
Merge pull request #1568 from Adyen/renovate/major-turbine_version
Browse files Browse the repository at this point in the history
Update dependency app.cash.turbine:turbine to v1
  • Loading branch information
jreij authored Apr 23, 2024
2 parents 971521d + 5ec8cde commit ee262d5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ package com.adyen.checkout.card.internal.ui

import androidx.annotation.StringRes
import app.cash.turbine.test
import app.cash.turbine.testIn
import com.adyen.checkout.card.AddressConfiguration
import com.adyen.checkout.card.CardBrand
import com.adyen.checkout.card.CardComponentState
Expand Down Expand Up @@ -59,6 +58,7 @@ import com.adyen.checkout.cse.internal.BaseGenericEncryptor
import com.adyen.checkout.cse.internal.test.TestCardEncryptor
import com.adyen.checkout.cse.internal.test.TestGenericEncryptor
import com.adyen.checkout.test.TestDispatcherExtension
import com.adyen.checkout.test.extensions.test
import com.adyen.checkout.ui.core.internal.data.api.AddressRepository
import com.adyen.checkout.ui.core.internal.test.TestAddressRepository
import com.adyen.checkout.ui.core.internal.ui.AddressFormUIState
Expand All @@ -70,6 +70,7 @@ import com.adyen.checkout.ui.core.internal.ui.model.AddressParams
import com.adyen.checkout.ui.core.internal.util.AddressFormUtils
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.UnconfinedTestDispatcher
Expand Down Expand Up @@ -141,22 +142,22 @@ internal class DefaultCardDelegateTest(
inner class InputDataChangedTest {
@Test
fun `address configuration is none, then countries and states should not be fetched`() = runTest {
val countriesFlow = addressRepository.countriesFlow.testIn(this)
val statesFlow = addressRepository.statesFlow.testIn(this)
val countriesFlow = addressRepository.countriesFlow.test(testScheduler)
val statesFlow = addressRepository.statesFlow.test(testScheduler)

delegate.initialize(CoroutineScope(UnconfinedTestDispatcher()))

countriesFlow.expectNoEvents()
statesFlow.expectNoEvents()
assert(countriesFlow.values.isEmpty())
assert(statesFlow.values.isEmpty())

countriesFlow.cancelAndIgnoreRemainingEvents()
statesFlow.cancelAndIgnoreRemainingEvents()
countriesFlow.cancel()
statesFlow.cancel()
}

@Test
fun `address configuration is postal code, then countries and states should not be fetched`() = runTest {
val countriesFlow = addressRepository.countriesFlow.testIn(this)
val statesFlow = addressRepository.statesFlow.testIn(this)
val countriesFlow = addressRepository.countriesFlow.test(testScheduler)
val statesFlow = addressRepository.statesFlow.test(testScheduler)
delegate = createCardDelegate(
configuration = createCheckoutConfiguration {
setAddressConfiguration(AddressConfiguration.PostalCode())
Expand All @@ -165,17 +166,17 @@ internal class DefaultCardDelegateTest(

delegate.initialize(CoroutineScope(UnconfinedTestDispatcher()))

countriesFlow.expectNoEvents()
statesFlow.expectNoEvents()
assert(countriesFlow.values.isEmpty())
assert(statesFlow.values.isEmpty())

countriesFlow.cancelAndIgnoreRemainingEvents()
statesFlow.cancelAndIgnoreRemainingEvents()
countriesFlow.cancel()
statesFlow.cancel()
}

@Test
fun `address repository returns error, then countries should be emitted empty`() = runTest {
val countriesFlow = addressRepository.countriesFlow.testIn(this)
val statesFlow = addressRepository.statesFlow.testIn(this)
val countriesFlow = addressRepository.countriesFlow.test(testScheduler)
val statesFlow = addressRepository.statesFlow.test(testScheduler)

addressRepository.shouldReturnError = true
delegate = createCardDelegate(
Expand All @@ -185,18 +186,18 @@ internal class DefaultCardDelegateTest(
)
delegate.initialize(CoroutineScope(UnconfinedTestDispatcher()))

assertTrue(countriesFlow.awaitItem().isEmpty())
statesFlow.expectNoEvents()
assertTrue(countriesFlow.latestValue.isEmpty())
assert(statesFlow.values.isEmpty())

countriesFlow.cancelAndIgnoreRemainingEvents()
statesFlow.cancelAndIgnoreRemainingEvents()
countriesFlow.cancel()
statesFlow.cancel()
}

@Test
fun `address configuration is full address with default country, then countries and states should be emitted`() =
runTest {
val countriesFlow = addressRepository.countriesFlow.testIn(this)
val statesFlow = addressRepository.statesFlow.testIn(this)
val countriesFlow = addressRepository.countriesFlow.test(testScheduler)
val statesFlow = addressRepository.statesFlow.test(testScheduler)

delegate = createCardDelegate(
configuration = createCheckoutConfiguration {
Expand All @@ -205,18 +206,18 @@ internal class DefaultCardDelegateTest(
)
delegate.initialize(CoroutineScope(UnconfinedTestDispatcher()))

assertEquals(TestAddressRepository.COUNTRIES, countriesFlow.awaitItem())
assertEquals(TestAddressRepository.STATES, statesFlow.awaitItem())
assertEquals(TestAddressRepository.COUNTRIES, countriesFlow.latestValue)
assertEquals(TestAddressRepository.STATES, statesFlow.latestValue)

countriesFlow.cancelAndIgnoreRemainingEvents()
statesFlow.cancelAndIgnoreRemainingEvents()
countriesFlow.cancel()
statesFlow.cancel()
}

@Test
fun `address configuration is full address without default country, then only countries should be emitted`() =
runTest {
val countriesFlow = addressRepository.countriesFlow.testIn(this)
val statesFlow = addressRepository.statesFlow.testIn(this)
val countriesFlow = addressRepository.countriesFlow.test(testScheduler)
val statesFlow = addressRepository.statesFlow.test(testScheduler)

delegate = createCardDelegate(
configuration = createCheckoutConfiguration(shopperLocale = Locale.CANADA) {
Expand All @@ -225,11 +226,11 @@ internal class DefaultCardDelegateTest(
)
delegate.initialize(CoroutineScope(UnconfinedTestDispatcher()))

assertEquals(TestAddressRepository.COUNTRIES, countriesFlow.awaitItem())
statesFlow.expectNoEvents()
assertEquals(TestAddressRepository.COUNTRIES, countriesFlow.latestValue)
assert(statesFlow.values.isEmpty())

countriesFlow.cancelAndIgnoreRemainingEvents()
statesFlow.cancelAndIgnoreRemainingEvents()
countriesFlow.cancel()
statesFlow.cancel()
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ ext {
robolectric_version = "4.11.1"
test_ext_version = "1.1.5"
test_rules_version = "1.5.0"
turbine_version = "0.12.1"
turbine_version = "1.1.0"
uiautomator_version = "2.2.0"

libraries = [
Expand Down
16 changes: 16 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2252,6 +2252,14 @@
<sha256 value="a2fd491ed3657d251517e3013a3306954fa07aeab8f67a125d74963acd00a886" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="app.cash.turbine" name="turbine" version="1.1.0">
<artifact name="Turbine-metadata.jar">
<sha256 value="ef32d46a2e2e04b748f8e105ebb96508ba2f7c0cf28f689a3160774f33bee22d" origin="Generated by Gradle"/>
</artifact>
<artifact name="turbine-1.1.0.module">
<sha256 value="74c94344524b0ab306f2770f1daec40a273483652a492eae3b1bbf71dde4ce47" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="app.cash.turbine" name="turbine-jvm" version="0.12.1">
<artifact name="turbine-jvm-0.12.1.jar">
<sha256 value="23e8a0f17532838916b55c993af12cc3e46ff1f435cae0451ac8b1cad6669101" origin="Generated by Gradle"/>
Expand All @@ -2260,6 +2268,14 @@
<sha256 value="4de32650549fa5e829ae70391108f4df1e086f3ea5cf82490690c449e414a438" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="app.cash.turbine" name="turbine-jvm" version="1.1.0">
<artifact name="Turbine-jvm.jar">
<sha256 value="9b779f2390bc0e56c5f86cbf3552b0b41b53e4c2c2322b53ba1f796054026356" origin="Generated by Gradle"/>
</artifact>
<artifact name="turbine-jvm-1.1.0.module">
<sha256 value="ba7cc8f9f368b437ccb16a5af704167696cd4f00ea8e67ca7243acaff6c99cd3" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="ch.qos.logback" name="logback-classic" version="1.3.14">
<artifact name="logback-classic-1.3.14.jar">
<sha256 value="f9b07a6dba4df3899381df7e597df450134e1879b1f3a757456b3cd1c8d94e2f" origin="Generated by Gradle"/>
Expand Down

0 comments on commit ee262d5

Please sign in to comment.