File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
main/java/com/paypal/android/cardpayments
test/java/com/paypal/android/cardpayments Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ class CardClient internal constructor(
38
38
var cardVaultListener: CardVaultListener ? = null
39
39
40
40
private var approveOrderId: String? = null
41
- private val lifeCycleObserver = CardLifeCycleObserver (this )
41
+ internal val lifeCycleObserver = CardLifeCycleObserver (this )
42
42
43
43
private val activityReference = WeakReference (activity)
44
44
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ import org.junit.Before
29
29
import org.junit.Test
30
30
import org.junit.runner.RunWith
31
31
import org.robolectric.RobolectricTestRunner
32
+ import strikt.api.expectThat
33
+ import strikt.assertions.isNull
32
34
33
35
@ExperimentalCoroutinesApi
34
36
@RunWith(RobolectricTestRunner ::class )
@@ -359,4 +361,18 @@ class CardClientUnitTest {
359
361
sut.cardVaultListener = cardVaultListener
360
362
return sut
361
363
}
364
+
365
+ @Test
366
+ fun `when client is complete, lifecycle observer is removed` () = runTest {
367
+ val sut = createCardClient(testScheduler)
368
+
369
+ val lifeCycle = mockk<Lifecycle >(relaxed = true )
370
+ every { activity.lifecycle } returns lifeCycle
371
+
372
+ sut.removeObservers()
373
+
374
+ verify { lifeCycle.removeObserver(sut.lifeCycleObserver) }
375
+ expectThat(sut.approveOrderListener).isNull()
376
+ expectThat(sut.cardVaultListener).isNull()
377
+ }
362
378
}
You can’t perform that action at this time.
0 commit comments