feat(medusa, medusa-js, medusa-react): Implement Sales Channel retrieval (#1793)

This commit is contained in:
Adrien de Peretti
2022-07-06 12:17:26 +02:00
committed by GitHub
parent e115518dda
commit 263a661031
26 changed files with 511 additions and 34 deletions

View File

@@ -0,0 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`sales channels GET /admin/sales-channels/:id should retrieve the requested sales channel 1`] = `
Object {
"created_at": Any<String>,
"deleted_at": null,
"description": "test description",
"id": Any<String>,
"is_disabled": false,
"name": "test name",
"updated_at": Any<String>,
}
`;

View File

@@ -2,10 +2,19 @@ const path = require("path")
const { useApi } = require("../../../helpers/use-api")
const { useDb } = require("../../../helpers/use-db")
const adminSeeder = require("../../helpers/admin-seeder")
const { simpleSalesChannelFactory, } = require("../../factories")
const startServerWithEnvironment =
require("../../../helpers/start-server-with-environment").default
const adminReqConfig = {
headers: {
Authorization: "Bearer test_token",
},
}
jest.setTimeout(30000)
describe("sales channels", () => {
@@ -36,7 +45,46 @@ describe("sales channels", () => {
})
})
describe("POST /admin/sales-channels", () => {})
describe("GET /admin/sales-channels/:id", () => {})
describe("GET /admin/sales-channels/:id", () => {
let salesChannel
beforeEach(async() => {
try {
await adminSeeder(dbConnection)
salesChannel = await simpleSalesChannelFactory(dbConnection, {
name: "test name",
description: "test description",
})
} catch (e) {
console.error(e)
}
})
afterEach(async() => {
const db = useDb()
await db.teardown()
})
it("should retrieve the requested sales channel", async() => {
const api = useApi()
const response = await api.get(
`/admin/sales-channels/${salesChannel.id}`,
adminReqConfig
)
expect(response.status).toEqual(200)
expect(response.data.sales_channel).toBeTruthy()
expect(response.data.sales_channel).toMatchSnapshot({
id: expect.any(String),
name: salesChannel.name,
description: salesChannel.description,
created_at: expect.any(String),
updated_at: expect.any(String),
})
})
})
describe("POST /admin/sales-channels/:id", () => {})
describe("DELETE /admin/sales-channels/:id", () => {})
})