fix: make it possible to update order shipping address (#668)

This commit is contained in:
Sebastian Rindom
2021-11-05 16:48:29 +01:00
committed by GitHub
parent 45b344fbe1
commit e0fa06fe96
3 changed files with 93 additions and 7 deletions

View File

@@ -0,0 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`/admin/orders POST /admin/orders/:id updates a shipping adress 1`] = `
Object {
"address_1": "Some Street",
"address_2": "",
"city": "losangeles",
"company": null,
"country_code": "us",
"created_at": Any<String>,
"customer_id": null,
"deleted_at": null,
"first_name": "lebron",
"id": Any<String>,
"last_name": null,
"metadata": null,
"phone": null,
"postal_code": "1235",
"province": "",
"updated_at": Any<String>,
}
`;

View File

@@ -74,6 +74,63 @@ describe("/admin/orders", () => {
})
})
describe("POST /admin/orders/:id", () => {
beforeEach(async () => {
try {
await adminSeeder(dbConnection)
await orderSeeder(dbConnection)
} catch (err) {
throw err
}
})
afterEach(async () => {
const db = useDb()
await db.teardown()
})
it("updates a shipping adress", async () => {
const api = useApi()
const response = await api
.post(
"/admin/orders/test-order",
{
email: "test@test.com",
shipping_address: {
address_1: "Some Street",
address_2: "",
province: "",
postal_code: "1235",
city: "losangeles",
country_code: "us",
},
},
{
headers: {
authorization: "Bearer test_token",
},
}
)
.catch((err) => {
console.log(err.response.data)
})
expect(response.status).toEqual(200)
expect(response.data.order.shipping_address).toMatchSnapshot({
id: expect.any(String),
address_1: "Some Street",
address_2: "",
province: "",
postal_code: "1235",
city: "losangeles",
country_code: "us",
created_at: expect.any(String),
updated_at: expect.any(String),
})
})
})
describe("GET /admin/orders", () => {
beforeEach(async () => {
try {