Skip to content

Commit

Permalink
Revert "Fix tests - set mock activity to return intent"
Browse files Browse the repository at this point in the history
This reverts commit 3f67c25.
  • Loading branch information
Maddie Beyl committed Jan 7, 2022
1 parent 2288592 commit 045ebf8
Showing 1 changed file with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.revenuecat.purchases.google

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Handler
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.billingclient.api.AcknowledgePurchaseParams
Expand Down Expand Up @@ -81,7 +80,6 @@ class BillingWrapperTest {

private val billingClientOKResult = BillingClient.BillingResponseCode.OK.buildResult()
private val appUserId = "jerry"
private var mockActivity = mockk<Activity>()

@Before
fun setup() {
Expand Down Expand Up @@ -147,10 +145,6 @@ class BillingWrapperTest {
onConnectedCalled = true
}
}

every {
mockActivity.intent
} returns Intent()
}

@Test
Expand Down Expand Up @@ -258,9 +252,11 @@ class BillingWrapperTest {

val skuDetails = stubSkuDetails(productId = "product_a")

val activity: Activity = mockk()

billingClientStateListener!!.onBillingSetupFinished(BillingClient.BillingResponseCode.OK.buildResult())
wrapper.makePurchaseAsync(
mockActivity,
activity,
appUserId,
skuDetails.toStoreProduct(),
mockReplaceSkuInfo(),
Expand All @@ -269,7 +265,7 @@ class BillingWrapperTest {

verify {
mockClient.launchBillingFlow(
eq(mockActivity),
eq(activity),
any()
)
}
Expand Down Expand Up @@ -309,11 +305,12 @@ class BillingWrapperTest {
@BillingClient.SkuType val skuType = BillingClient.SkuType.SUBS

val upgradeInfo = mockReplaceSkuInfo()
val activity: Activity = mockk()
val skuDetails = stubSkuDetails(productId = sku, type = skuType)

val slot = slot<BillingFlowParams>()
every {
mockClient.launchBillingFlow(eq(mockActivity), capture(slot))
mockClient.launchBillingFlow(eq(activity), capture(slot))
} answers {
val capturedSkuDetails = skuDetailsSlot.captured

Expand All @@ -327,7 +324,7 @@ class BillingWrapperTest {

billingClientStateListener!!.onBillingSetupFinished(BillingClient.BillingResponseCode.OK.buildResult())
wrapper.makePurchaseAsync(
mockActivity,
activity,
appUserId,
skuDetails.toStoreProduct(),
upgradeInfo,
Expand All @@ -340,7 +337,7 @@ class BillingWrapperTest {
val mockBuilder = setUpForObfuscatedAccountIDTests()

wrapper.makePurchaseAsync(
mockActivity,
mockk(),
appUserId,
stubSkuDetails(productId = "product_a").toStoreProduct(),
null,
Expand All @@ -360,7 +357,7 @@ class BillingWrapperTest {
val mockBuilder = setUpForObfuscatedAccountIDTests()

wrapper.makePurchaseAsync(
mockActivity,
mockk(),
appUserId,
stubSkuDetails(productId = "product_a").toStoreProduct(),
mockReplaceSkuInfo(),
Expand All @@ -382,26 +379,27 @@ class BillingWrapperTest {

every { mockClient.isReady } returns false

val activity: Activity = mockk()
val skuDetails = stubSkuDetails(productId = "product_a")

wrapper.makePurchaseAsync(
mockActivity,
activity,
appUserId,
skuDetails.toStoreProduct(),
mockReplaceSkuInfo(),
null
)

verify(exactly = 0) {
mockClient.launchBillingFlow(eq(mockActivity), any())
mockClient.launchBillingFlow(eq(activity), any())
}

every { mockClient.isReady } returns true

billingClientStateListener!!.onBillingSetupFinished(BillingClient.BillingResponseCode.OK.buildResult())

verify(exactly = 1) {
mockClient.launchBillingFlow(eq(mockActivity), any())
mockClient.launchBillingFlow(eq(activity), any())
}
}

Expand All @@ -415,8 +413,10 @@ class BillingWrapperTest {

val skuDetails = stubSkuDetails(productId = "product_a")

val activity: Activity = mockk()

wrapper.makePurchaseAsync(
mockActivity,
activity,
appUserId,
skuDetails.toStoreProduct(),
mockReplaceSkuInfo(),
Expand Down Expand Up @@ -809,9 +809,11 @@ class BillingWrapperTest {

val skuDetails = stubSkuDetails(productId = "product_a")

val activity: Activity = mockk()

billingClientStateListener!!.onBillingSetupFinished(BillingClient.BillingResponseCode.OK.buildResult())
wrapper.makePurchaseAsync(
mockActivity,
activity,
appUserId,
skuDetails.toStoreProduct(),
mockReplaceSkuInfo(),
Expand Down

0 comments on commit 045ebf8

Please sign in to comment.