Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ fun generateTestOrder(): UpdatedOrder {
generateTestOnTotalDiscountInfo(),
generateTestOnMembershipDiscountInfo(),
generateTestOnTotalAndMembershipDiscountInfo(),
generateTestCustomDiscountInfo()
generateTestCustomDiscountInfo(),
generateTestItemDiscountInfo(),
generateTestShippingDiscountInfo(),
generateTestSubtotalDiscountInfo()
),

// TODO Pass real discount coupon code when API client will support this
Expand Down Expand Up @@ -190,6 +193,30 @@ private fun generateTestCustomDiscountInfo() = UpdatedOrder.DiscountInfo(
description = "Custom discount " + randomAlphanumeric(8)
)

private fun generateTestItemDiscountInfo() = UpdatedOrder.DiscountInfo(
value = randomPrice(),
type = randomEnumValue<DiscountType>(),
base = DiscountBase.ITEM,
orderTotal = randomPrice(),
description = "On item discount " + randomAlphanumeric(8)
)

private fun generateTestShippingDiscountInfo() = UpdatedOrder.DiscountInfo(
value = randomPrice(),
type = randomEnumValue<DiscountType>(),
base = DiscountBase.SHIPPING,
orderTotal = randomPrice(),
description = "On shipping discount " + randomAlphanumeric(8)
)

private fun generateTestSubtotalDiscountInfo() = UpdatedOrder.DiscountInfo(
value = randomPrice(),
type = randomEnumValue<DiscountType>(),
base = DiscountBase.SUBTOTAL,
orderTotal = randomPrice(),
description = "On subtotal discount " + randomAlphanumeric(8)
)

private fun generateTestOrderItem() = UpdatedOrder.OrderItem(
// var id: Int? = null, // TODO readonly
// productId = com.ecwid.api.v3.randomId(), // TODO need to pass existing product id
Expand Down
Loading