feat(medusa): Support deleting prices from a price list by product or variant (#1555)
This commit is contained in:
@@ -3,6 +3,8 @@ import {
|
||||
useAdminCreatePriceListPrices,
|
||||
useAdminDeletePriceList,
|
||||
useAdminDeletePriceListPrices,
|
||||
useAdminDeletePriceListProductPrices,
|
||||
useAdminDeletePriceListVariantPrices,
|
||||
useAdminUpdatePriceList,
|
||||
} from "../../../../src"
|
||||
import { renderHook } from "@testing-library/react-hooks"
|
||||
@@ -137,3 +139,53 @@ describe("useAdminDeletePriceList hook", () => {
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("useAdminDeletePriceListProductPrices hook", () => {
|
||||
test("should delete prices from a price list for all the variants related to the specified product", async () => {
|
||||
const { result, waitFor } = renderHook(
|
||||
() => useAdminDeletePriceListProductPrices(
|
||||
fixtures.get("price_list").id,
|
||||
fixtures.get("product").id
|
||||
),
|
||||
{
|
||||
wrapper: createWrapper(),
|
||||
}
|
||||
)
|
||||
|
||||
result.current.mutate()
|
||||
|
||||
await waitFor(() => result.current.isSuccess)
|
||||
|
||||
expect(result.current.data.response.status).toEqual(200)
|
||||
expect(result.current.data).toEqual(expect.objectContaining({
|
||||
ids: [],
|
||||
object: "money-amount",
|
||||
deleted: true
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
describe("useAdminDeletePriceListVariantPrices hook", () => {
|
||||
test("should delete prices from a price list for the specified variant", async () => {
|
||||
const { result, waitFor } = renderHook(
|
||||
() => useAdminDeletePriceListVariantPrices(
|
||||
fixtures.get("price_list").id,
|
||||
fixtures.get("product_variant").id
|
||||
),
|
||||
{
|
||||
wrapper: createWrapper(),
|
||||
}
|
||||
)
|
||||
|
||||
result.current.mutate()
|
||||
|
||||
await waitFor(() => result.current.isSuccess)
|
||||
|
||||
expect(result.current.data.response.status).toEqual(200)
|
||||
expect(result.current.data).toEqual(expect.objectContaining({
|
||||
ids: [],
|
||||
object: "money-amount",
|
||||
deleted: true
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user