feat(medusa, medusa-js, medusa-react): Bulk add Products to a SalesChannel (#1833)

This commit is contained in:
Adrien de Peretti
2022-07-14 16:39:44 +02:00
committed by GitHub
parent cdd91974f9
commit f35ea5156a
12 changed files with 377 additions and 20 deletions
@@ -5,6 +5,7 @@ import {
useAdminCreateSalesChannel,
useAdminUpdateSalesChannel,
useAdminDeleteProductsFromSalesChannel,
useAdminAddProductsToSalesChannel,
} from "../../../../src"
import { fixtures } from "../../../../mocks/data"
import { createWrapper } from "../../../utils"
@@ -107,3 +108,25 @@ describe("useAdminDeleteProductsFromSalesChannel hook", () => {
}))
})
})
describe("useAdminAddProductsToSalesChannel hook", () => {
test("add products to a sales channel", async () => {
const id = fixtures.get("sales_channel").id
const productId = fixtures.get("product").id
const { result, waitFor } = renderHook(
() => useAdminAddProductsToSalesChannel(id),
{ wrapper: createWrapper() }
)
result.current.mutate({ product_ids: [
{ id: productId }
]})
await waitFor(() => result.current.isSuccess)
expect(result.current.data).toEqual(expect.objectContaining({
sales_channel: fixtures.get("sales_channel"),
}))
})
})