Skip to content

Commit

Permalink
Update unit test for VARIABLE_PRODUCT case.
Browse files Browse the repository at this point in the history
  • Loading branch information
hafizrahman committed Dec 2, 2024
1 parent 6c78cef commit e5b5579
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,45 @@ class ProductDetailCardBuilderTest : BaseUnitTest() {
)
}

@Test
fun `given variable subscription product with one time shipping enabled, when building cards, then shipping includes one-time shipping`() = testBlocking {
productStub = ProductTestUtils.generateProduct()
.copy(
isVirtual = false,
type = ProductType.VARIABLE_SUBSCRIPTION.value,
weight = 1.5f,
length = 10f,
width = 20f,
height = 30f,
shippingClassId = 123
)

val subscriptionDetails = ProductHelper.getDefaultSubscriptionDetails().copy(
oneTimeShipping = true
)

val cards = sut.buildPropertyCards(
ProductAggregate(
product = productStub,
subscription = subscriptionDetails
),
""
)

val shippingGroup = cards.first { it.type == ProductPropertyCard.Type.SECONDARY }
.properties
.find {
it is ProductProperty.PropertyGroup &&
it.title == R.string.product_shipping
} as ProductProperty.PropertyGroup

val propertyKeys = shippingGroup.properties.toList().map { it.first }
Assertions.assertThat(propertyKeys).hasSize(4) // Weight, Dimensions, Shipping class, One-time shipping
Assertions.assertThat(propertyKeys).contains(
resourceProvider.getString(R.string.subscription_one_time_shipping)
)
}

@Test
fun `given simple non-virtual product, when building cards, then shipping excludes one-time shipping`() = testBlocking {
productStub = ProductTestUtils.generateProduct()
Expand Down

0 comments on commit e5b5579

Please sign in to comment.