Fix: admin api create customer (#826)

This commit is contained in:
Derek Wene
2021-11-20 04:50:28 -06:00
committed by GitHub
parent f162b4a2a1
commit ebb7c0aa53
2 changed files with 50 additions and 1 deletions

View File

@@ -132,6 +132,55 @@ describe("/admin/customers", () => {
})
})
describe("POST /admin/customers", () => {
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
} catch (err) {
console.log(err)
throw err
}
})
afterEach(async () => {
const db = useDb()
await db.teardown()
})
it("Correctly creates customer", async () => {
const api = useApi()
const response = await api
.post(
"/admin/customers",
{
first_name: "newf",
last_name: "newl",
email: "new@email.com",
password: "newpassword",
metadata: { foo: "bar" },
},
{
headers: {
Authorization: "Bearer test_token",
},
}
)
.catch((err) => {
console.log(err)
})
expect(response.status).toEqual(201)
expect(response.data.customer).toEqual(
expect.objectContaining({
first_name: "newf",
last_name: "newl",
email: "new@email.com",
metadata: { foo: "bar" },
})
)
})
})
describe("POST /admin/customers/:id", () => {
beforeEach(async () => {
try {