feat(medusa, medusa-js, medusa-react): Implement Sales Channel list (#1815)

**What**
Support sales channel list in medusa, medusa-js and medusa-react

**How**

By implementing a new endpoint and the associated service method as well as the repository methods.

Medusa-js new list method in the resource

Medusa-react new hook in the queries

**Tests**

Endpoint test
Service test
Integration test
Hook tests

Fixes CORE-280
This commit is contained in:
Adrien de Peretti
2022-07-13 10:28:53 +00:00
committed by GitHub
parent c20d720040
commit a1a5848827
23 changed files with 750 additions and 53 deletions
@@ -1,10 +1,10 @@
import { useAdminSalesChannel } from "../../../../src"
import { useAdminSalesChannel, useAdminSalesChannels } from "../../../../src"
import { renderHook } from "@testing-library/react-hooks"
import { fixtures } from "../../../../mocks/data"
import { createWrapper } from "../../../utils"
describe("useAdminSalesChannel hook", () => {
test("returns a product", async () => {
test("returns a sales channel", async () => {
const salesChannel = fixtures.get("sales_channel")
const { result, waitFor } = renderHook(
() => useAdminSalesChannel(salesChannel.id),
@@ -19,3 +19,17 @@ describe("useAdminSalesChannel hook", () => {
expect(result.current.sales_channel).toEqual(salesChannel)
})
})
describe("useAdminSalesChannels hook", () => {
test("returns a list of sales channels", async () => {
const salesChannels = fixtures.get("sales_channels")
const { result, waitFor } = renderHook(() => useAdminSalesChannels(), {
wrapper: createWrapper(),
})
await waitFor(() => result.current.isSuccess)
expect(result.current.response.status).toEqual(200)
expect(result.current.sales_channels).toEqual(salesChannels)
})
})