Skip to content

Commit f332616

Browse files
committed
Test when 3+1 and remove item
1 parent b49a1f3 commit f332616

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

ecommerce/pricing/test/three_plus_one_test.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,5 +395,44 @@ def test_given_three_plus_one_promotion_when_eight_items_are_added_then_two_item
395395
)
396396
) { add_item(order_id, product_id, promotion: true) }
397397
end
398+
399+
def test_given_three_plus_one_is_applied_when_item_is_removed_then_the_discount_is_removed
400+
product_id = SecureRandom.uuid
401+
set_price(product_id, 20)
402+
order_id = SecureRandom.uuid
403+
stream = "Pricing::Offer$#{order_id}"
404+
405+
4.times { add_item(order_id, product_id, promotion: true) }
406+
407+
assert_events(
408+
stream,
409+
PriceItemRemoved.new(
410+
data: {
411+
order_id: order_id,
412+
product_id: product_id,
413+
base_price: 20,
414+
price: 0,
415+
base_total_value: 60,
416+
total_value: 60
417+
}
418+
),
419+
OrderTotalValueCalculated.new(
420+
data: {
421+
order_id: order_id,
422+
total_amount: 60,
423+
discounted_amount: 60
424+
}
425+
),
426+
PriceItemValueCalculated.new(
427+
data: {
428+
order_id: order_id,
429+
product_id: product_id,
430+
quantity: 3,
431+
amount: 60,
432+
discounted_amount: 60,
433+
}
434+
)
435+
) { remove_item(order_id, product_id) }
436+
end
398437
end
399438
end

0 commit comments

Comments
 (0)