-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/test/kotlin/com/petqua/domain/order/OrderPaymentTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.petqua.domain.order | ||
|
||
import com.petqua.domain.order.OrderStatus.CANCELED | ||
import com.petqua.domain.order.OrderStatus.PAYMENT_CONFIRMED | ||
import com.petqua.exception.order.OrderException | ||
import com.petqua.exception.order.OrderExceptionType | ||
import com.petqua.test.fixture.orderPayment | ||
import io.kotest.assertions.assertSoftly | ||
import io.kotest.assertions.throwables.shouldThrow | ||
import io.kotest.core.spec.style.StringSpec | ||
import io.kotest.matchers.shouldBe | ||
|
||
class OrderPaymentTest : StringSpec({ | ||
|
||
"결제를 진행한다" { | ||
val orderPayment = orderPayment() | ||
val payedOrderPayment = orderPayment.pay(tossPaymentId = 1L) | ||
|
||
assertSoftly(payedOrderPayment) { | ||
orderId shouldBe orderPayment.orderId | ||
tossPaymentId shouldBe 1L | ||
status shouldBe PAYMENT_CONFIRMED | ||
prevId shouldBe orderPayment.id | ||
} | ||
} | ||
|
||
"결제 시도시 결제가 가능한 상태가 아니라면 예외를 던진다" { | ||
val orderPayment = orderPayment( | ||
status = PAYMENT_CONFIRMED | ||
) | ||
|
||
shouldThrow<OrderException> { | ||
orderPayment.pay(tossPaymentId = 1L) | ||
}.exceptionType() shouldBe OrderExceptionType.ORDER_CAN_NOT_PAY | ||
} | ||
|
||
"주문을 취소한다" { | ||
val orderPayment = orderPayment() | ||
val payedOrderPayment = orderPayment.cancel() | ||
|
||
assertSoftly(payedOrderPayment) { | ||
orderId shouldBe orderPayment.orderId | ||
tossPaymentId shouldBe orderPayment.tossPaymentId | ||
status shouldBe CANCELED | ||
prevId shouldBe orderPayment.id | ||
} | ||
} | ||
}) |