feat(medusa): Support batch remove resources on discount condition (#2444)
**what** - Add support to remove resources by batch on discount conditions - Add support on medusa-js and medusa-react **Tests** - Add integration tests to validate that the resources have been deleted and the length is the one expected - Add unit tests on medusa react FIXES CORE-609
This commit is contained in:
committed by
GitHub
parent
765a2cccda
commit
48411157b1
@@ -6,6 +6,7 @@ import {
|
||||
useAdminCreateDiscount,
|
||||
useAdminCreateDynamicDiscountCode,
|
||||
useAdminDeleteDiscount,
|
||||
useAdminDeleteDiscountConditionResourceBatch,
|
||||
useAdminDeleteDynamicDiscountCode,
|
||||
useAdminDiscountAddRegion,
|
||||
useAdminDiscountCreateCondition,
|
||||
@@ -16,6 +17,48 @@ import {
|
||||
} from "../../../../src/"
|
||||
import { createWrapper } from "../../../utils"
|
||||
|
||||
describe("useAdminDeleteDiscountConditionResourceBatch hook", () => {
|
||||
test("delete items from a discount condition and return the discount", async () => {
|
||||
const resources = [
|
||||
{
|
||||
id: fixtures.get("product").id,
|
||||
},
|
||||
]
|
||||
const discountId = fixtures.get("discount").id
|
||||
const conditionId = fixtures.get("discount").rule.conditions[0].id
|
||||
|
||||
const { result, waitFor } = renderHook(
|
||||
() =>
|
||||
useAdminDeleteDiscountConditionResourceBatch(discountId, conditionId),
|
||||
{
|
||||
wrapper: createWrapper(),
|
||||
}
|
||||
)
|
||||
|
||||
result.current.mutate({
|
||||
resources,
|
||||
})
|
||||
|
||||
await waitFor(() => result.current.isSuccess)
|
||||
|
||||
expect(result.current.data.response.status).toEqual(200)
|
||||
expect(result.current.data.discount).toEqual(
|
||||
expect.objectContaining({
|
||||
...fixtures.get("discount"),
|
||||
rule: {
|
||||
...fixtures.get("discount").rule,
|
||||
conditions: [
|
||||
{
|
||||
...fixtures.get("discount").rule.conditions[0],
|
||||
products: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("useAdminAddDiscountConditionResourceBatch hook", () => {
|
||||
test("add items to a discount condition and return the discount", async () => {
|
||||
const resources = [
|
||||
|
||||
Reference in New Issue
Block a user