fix: Throw on cart creation when no region exist (#455)
If you try to create a cart without a region in your setup, we should throw a proper error message.
This commit is contained in:
committed by
GitHub
parent
eb95b4d7bc
commit
17b192fe37
@@ -63,6 +63,24 @@ describe("/store/carts", () => {
|
||||
expect(getRes.status).toEqual(200)
|
||||
})
|
||||
|
||||
it("fails to create a cart when no region exist", async () => {
|
||||
const api = useApi()
|
||||
|
||||
await dbConnection.manager.query(
|
||||
`UPDATE "country" SET region_id=null WHERE iso_2 = 'us'`
|
||||
)
|
||||
await dbConnection.manager.query(`DELETE from region`)
|
||||
|
||||
try {
|
||||
await api.post("/store/carts")
|
||||
} catch (error) {
|
||||
expect(error.response.status).toEqual(400)
|
||||
expect(error.response.data.message).toEqual(
|
||||
"A region is required to create a cart"
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it("creates a cart with country", async () => {
|
||||
const api = useApi()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user