Skip to content

Commit

Permalink
feat(health-sdk): Added test case for hiding "powered by Gini"
Browse files Browse the repository at this point in the history
  • Loading branch information
llevente committed Jul 8, 2024
1 parent 23e30bf commit 5a61a19
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import android.widget.Button
import android.widget.FrameLayout
import android.widget.TextView
import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
import androidx.test.core.app.ActivityScenario
import androidx.test.core.app.ApplicationProvider
import com.google.common.truth.Truth
import io.mockk.mockk
import io.mockk.verify
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.test.runTest
import net.gini.android.health.sdk.R
import net.gini.android.health.sdk.paymentcomponent.PaymentComponent
import net.gini.android.health.sdk.paymentcomponent.PaymentComponentConfiguration
import net.gini.android.health.sdk.paymentcomponent.PaymentComponentView
import org.junit.After
import org.junit.Before
Expand All @@ -29,13 +30,15 @@ class PaymentComponentViewTest {
private var context: Context? = null
private var scenario: ActivityScenario<Activity>? = null
private lateinit var paymentComponent: PaymentComponent
private lateinit var paymentComponentBrandedOff: PaymentComponent
private lateinit var paymentComponentListener: PaymentComponent.Listener

@Before
fun setUp() {
context = ApplicationProvider.getApplicationContext()
context!!.setTheme(R.style.GiniHealthTheme)
paymentComponent = PaymentComponent(context!!, mockk())
paymentComponentBrandedOff = PaymentComponent(context!!, mockk(), PaymentComponentConfiguration(isPaymentComponentBranded = false))
paymentComponentListener = mockk(relaxed = true)
paymentComponent.listener = paymentComponentListener

Expand Down Expand Up @@ -145,4 +148,17 @@ class PaymentComponentViewTest {
Truth.assertThat((paymentComponentView.findViewById(R.id.ghs_select_bank_button) as Button).isEnabled).isEqualTo(false)
}
}
}

@Test
fun `hides powered by Gini`() = runTest {
// Given
scenario?.onActivity { activity ->
val paymentComponentView = PaymentComponentView(activity, null)
paymentComponentView.paymentComponent = paymentComponentBrandedOff
paymentComponentView.isPayable = true

// Then
Truth.assertThat((paymentComponentView.findViewById<FrameLayout>(R.id.ghs_powered_by_gini)!!).isVisible).isEqualTo(false)
}
}
}

0 comments on commit 5a61a19

Please sign in to comment.