feat(medusa): Support deleting prices from a price list by product or variant (#1555)

This commit is contained in:
Adrien de Peretti
2022-05-30 09:41:57 +02:00
committed by GitHub
parent ad9cfedf04
commit fa031fd28b
16 changed files with 602 additions and 78 deletions
@@ -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
}))
})
})