feat(medusa,medusa-react): PaymentCollection support (#2659)
* chore: medusa react, order edit complete fix and single payment session
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import {
|
||||
useAdminPaymentsCapturePayment,
|
||||
useAdminPaymentsRefundPayment,
|
||||
} from "../../../../src"
|
||||
import { renderHook } from "@testing-library/react-hooks"
|
||||
import { createWrapper } from "../../../utils"
|
||||
import { RefundReason } from "@medusajs/medusa"
|
||||
|
||||
describe("useAdminPaymentsCapturePayment hook", () => {
|
||||
test("Capture a payment", async () => {
|
||||
const { result, waitFor } = renderHook(
|
||||
() => useAdminPaymentsCapturePayment("payment_id"),
|
||||
{
|
||||
wrapper: createWrapper(),
|
||||
}
|
||||
)
|
||||
|
||||
result.current.mutate()
|
||||
|
||||
await waitFor(() => result.current.isSuccess)
|
||||
|
||||
expect(result.current.data.response.status).toEqual(200)
|
||||
expect(result.current.data.payment).toEqual(
|
||||
expect.objectContaining({
|
||||
amount_captured: 900,
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("useAdminPaymentsRefundPayment hook", () => {
|
||||
test("Update a Payment Collection", async () => {
|
||||
const { result, waitFor } = renderHook(
|
||||
() => useAdminPaymentsRefundPayment("payment_id"),
|
||||
{
|
||||
wrapper: createWrapper(),
|
||||
}
|
||||
)
|
||||
|
||||
result.current.mutate({
|
||||
amount: 500,
|
||||
reason: RefundReason.DISCOUNT,
|
||||
note: "note to refund",
|
||||
})
|
||||
|
||||
await waitFor(() => result.current.isSuccess)
|
||||
|
||||
expect(result.current.data.response.status).toEqual(200)
|
||||
expect(result.current.data.refund).toEqual(
|
||||
expect.objectContaining({
|
||||
payment_id: "payment_id",
|
||||
amount: 500,
|
||||
reason: RefundReason.DISCOUNT,
|
||||
note: "note to refund",
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user