Skip to content

Commit

Permalink
Test unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
warmkesselj committed Apr 24, 2024
1 parent 22b429e commit 08c0d22
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class PayPalWebCheckoutClient internal constructor(

private val activityReference = WeakReference(activity)

private var observer = PayPalWebCheckoutLifeCycleObserver(this)
var observer = PayPalWebCheckoutLifeCycleObserver(this)

init {
activity.lifecycle.addObserver(observer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,16 @@ class PayPalWebCheckoutClientUnitTest {
PayPalWebCheckoutClient(activity, coreConfig, "")
verify { lifeCycle.addObserver(ofType(PayPalWebCheckoutLifeCycleObserver::class)) }
}

@Test
fun `when client is complete, lifecycle observer is removed`() {
val lifeCycle = mockk<Lifecycle>(relaxed = true)
every { activity.lifecycle } returns lifeCycle

sut.removeObservers()

verify { sut.observer == isNull() }
verify { sut.listener == isNull() }
verify { sut.vaultListener == isNull() }
}
}

0 comments on commit 08c0d22

Please sign in to comment.