feat(medusa, medusa-js, medusa-react): Implement Sales Channel deletion (#1804)

This commit is contained in:
Adrien de Peretti
2022-07-07 10:47:51 +02:00
committed by GitHub
parent 4d15e01c3e
commit 2d03634cfc
13 changed files with 368 additions and 21 deletions
@@ -1,6 +1,10 @@
import { renderHook } from "@testing-library/react-hooks"
import { useAdminCreateSalesChannel, useAdminUpdateSalesChannel } from "../../../../src"
import {
useAdminDeleteSalesChannel,
useAdminCreateSalesChannel,
useAdminUpdateSalesChannel,
} from "../../../../src"
import { fixtures } from "../../../../mocks/data"
import { createWrapper } from "../../../utils"
@@ -30,7 +34,7 @@ describe("useAdminCreateSalesChannel hook", () => {
})
describe("useAdminUpdateSalesChannel hook", () => {
test("updates a store", async () => {
test("updates a sales channel", async () => {
const salesChannel = {
name: "medusa sales channel",
description: "main sales channel for medusa",
@@ -57,3 +61,26 @@ describe("useAdminUpdateSalesChannel hook", () => {
})
})
})
describe("useAdminDeleteSalesChannel hook", () => {
test("deletes a sales channel", async () => {
const id = fixtures.get("sales_channel").id
const { result, waitFor } = renderHook(
() => useAdminDeleteSalesChannel(id),
{ wrapper: createWrapper() }
)
result.current.mutate()
await waitFor(() => result.current.isSuccess)
expect(result.current.data).toEqual(
expect.objectContaining({
id,
object: "sales-channel",
deleted: true,
})
)
})
})