Files
medusa-store/integration-tests/api/__tests__/admin/sales-channels.js

91 lines
2.3 KiB
JavaScript

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", () => {
let medusaProcess
let dbConnection
beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", ".."))
const [process, connection] = await startServerWithEnvironment({
cwd,
env: { MEDUSA_FF_SALES_CHANNELS: true },
})
dbConnection = connection
medusaProcess = process
})
afterAll(async () => {
const db = useDb()
await db.shutdown()
medusaProcess.kill()
})
describe("GET /admin/sales-channels", () => {
it("is true", () => {
// dummy test to ensure test suite passes
expect(true).toBeTruthy()
})
})
describe("POST /admin/sales-channels", () => {})
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", () => {})
})