Feat(medusa): remove item from order (#2273)

* wait for update to order edit model

* delete line item tests

* create remove method for lineitem with tax lines

* add remove item tests

* split delete allocation tests into two: more and less than total

* remove unused import

* cleanup

* add medusa-js and react endpoints

* pr feedback fixes

* linting

* remove unused relation from query

* remove removed-event and unused imports

* add await
This commit is contained in:
Philip Korsholm
2022-09-30 09:48:18 +02:00
committed by GitHub
parent 95c0dc653a
commit 00959f79bc
15 changed files with 811 additions and 11 deletions

View File

@@ -10,6 +10,7 @@ import {
useAdminOrderEditLineItem,
useAdminCancelOrderEdit,
useAdminUpdateOrderEdit,
useAdminOrderEditDeleteLineItem,
} from "../../../../src/"
import { fixtures } from "../../../../mocks/data"
import { createWrapper } from "../../../utils"
@@ -247,3 +248,32 @@ describe("useAdminConfirmOrderEdit hook", () => {
)
})
})
describe("useAdminOrderEditDeleteLineItem hook", () => {
test("Remove line item of an order edit and create an item change", async () => {
const id = "oe_1"
const itemId = "item_1"
const { result, waitFor } = renderHook(
() => useAdminOrderEditDeleteLineItem(id, itemId),
{
wrapper: createWrapper(),
}
)
result.current.mutate()
await waitFor(() => result.current.isSuccess)
expect(result.current.data.response.status).toEqual(200)
expect(result.current.data.order_edit).toEqual(
expect.objectContaining({
...fixtures.get("order_edit"),
changes: expect.arrayContaining([
expect.objectContaining({
type: 'item_remove'
}),
]),
})
)
})
})