1 import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
2 import { createAdminUser } from "../../../../helpers/create-admin-user"
3
4 jest.setTimeout(50000)
5
6 const env = {}
7 const adminHeaders = {
8 headers: { "x-medusa-access-token": "test_token" },
9 }
10
11 medusaIntegrationTestRunner({
12 env,
13 testSuite: ({ dbConnection, getContainer, api, dbUtils }) => {
14 describe("POST /admin/customers", () => {
15 let appContainer
16 beforeAll(async () => {
17 appContainer = getContainer()
18 await createAdminUser(dbConnection, adminHeaders, appContainer)
19
20 await dbUtils.snapshot()
21 })
22
23 it("should create a customer", async () => {
24 const response = await api.post(
25 `/admin/customers`,
26 {
27 first_name: "John",
28 last_name: "Doe",
29 },
30 adminHeaders
31 )
32
33 expect(response.status).toEqual(200)
34 expect(response.data.customer).toEqual(
35 expect.objectContaining({
36 id: expect.any(String),
37 first_name: "John",
38 last_name: "Doe",
39 created_by: expect.any(String),
40 })
41 )
42 })
43 })
44 },
45 })